Commit eac4b445 authored by Nicolas Dumazet's avatar Nicolas Dumazet

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
parent 504723a3
...@@ -116,9 +116,7 @@ class ExplanationCache: ...@@ -116,9 +116,7 @@ class ExplanationCache:
simulation_movement_id = simulation_movement.getId() simulation_movement_id = simulation_movement.getId()
insert_movement = True insert_movement = True
for path_id in container_path: for path_id in container_path:
if local_path_dict.get(path_id, None) is None: local_path_dict = local_path_dict.setdefault(path_id, {})
local_path_dict[path_id] = dict()
local_path_dict = local_path_dict[path_id]
if type(local_path_dict) is not types.DictType: if type(local_path_dict) is not types.DictType:
# A movement was already inserted # A movement was already inserted
insert_movement = False insert_movement = False
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment