From eac4b44546f04fa25c62a7bc5e0dbd5ae28afa54 Mon Sep 17 00:00:00 2001 From: Nicolas Dumazet <nicolas.dumazet@nexedi.com> Date: Thu, 1 Jul 2010 01:47:06 +0000 Subject: [PATCH] dict.setdefault is a nice way to do this git-svn-id: https://svn.erp5.org/repos/public/erp5/sandbox/amount_generator@36760 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5/ExplanationCache.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/product/ERP5/ExplanationCache.py b/product/ERP5/ExplanationCache.py index 3f220d86e5..21a1db3e0f 100644 --- a/product/ERP5/ExplanationCache.py +++ b/product/ERP5/ExplanationCache.py @@ -116,9 +116,7 @@ class ExplanationCache: simulation_movement_id = simulation_movement.getId() insert_movement = True for path_id in container_path: - if local_path_dict.get(path_id, None) is None: - local_path_dict[path_id] = dict() - local_path_dict = local_path_dict[path_id] + local_path_dict = local_path_dict.setdefault(path_id, {}) if type(local_path_dict) is not types.DictType: # A movement was already inserted insert_movement = False @@ -300,4 +298,4 @@ def _getUnionBusinessProcess(explanation): which are involved in the simulation trees related to explanation """ explanation_cache = _getExplanationCache(explanation) - return explanation_cache.getUnionBusinessProcess() \ No newline at end of file + return explanation_cache.getUnionBusinessProcess() -- 2.30.9