Merge lp:~sidnei/juju-deployer/relation-not-in-target into lp:~gandelman-a/juju-deployer/trunk

Proposed by Sidnei da Silva
Status: Merged
Merged at revision: 69
Proposed branch: lp:~sidnei/juju-deployer/relation-not-in-target
Merge into: lp:~gandelman-a/juju-deployer/trunk
Diff against target: 22 lines (+6/-7)
1 file modified
utils.py (+6/-7)
To merge this branch: bzr merge lp:~sidnei/juju-deployer/relation-not-in-target
Reviewer Review Type Date Requested Status
Adam Gandelman Pending
Review via email: mp+152811@code.launchpad.net

Description of the change

If a relation is present in source but not in target in relations_combine, it would blow up because the 2nd check (isinstance(target[key], list)) didn't check for 'key' being present in 'target'.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'utils.py'
2--- utils.py 2013-03-04 19:14:17 +0000
3+++ utils.py 2013-03-12 03:35:25 +0000
4@@ -29,14 +29,13 @@
5 def relations_combine(onto, source):
6 target = deepcopy(onto)
7 for (key, value) in source.items():
8- if (key in target and isinstance(target[key], dict) and
9- isinstance(value, dict)):
10- target[key] = relations_combine(target[key], value)
11- else:
12- if isinstance(target[key], list) and isinstance(value, list):
13+ if key in target:
14+ if isinstance(target[key], dict) and isinstance(value, dict):
15+ target[key] = relations_combine(target[key], value)
16+ elif isinstance(target[key], list) and isinstance(value, list):
17 target[key] = list(set(target[key] + value))
18- else:
19- target[key] = value
20+ else:
21+ target[key] = value
22 return target
23
24

Subscribers

People subscribed via source and target branches