Merge lp:~tycho-s/simplestreams/fix-condense into lp:~smoser/simplestreams/trunk

Proposed by Tycho Andersen
Status: Merged
Merged at revision: 348
Proposed branch: lp:~tycho-s/simplestreams/fix-condense
Merge into: lp:~smoser/simplestreams/trunk
Diff against target: 80 lines (+19/-9)
2 files modified
simplestreams/util.py (+4/-3)
tests/unittests/test_util.py (+15/-6)
To merge this branch: bzr merge lp:~tycho-s/simplestreams/fix-condense
Reviewer Review Type Date Requested Status
Scott Moser Pending
Review via email: mp+222564@code.launchpad.net

Commit message

A few fixes to condense:

* hoist unicode stuff correctly
* hoist tags out of versions into being siblings of products

Description of the change

A few fixes to condense:

* hoist unicode stuff correctly
* hoist tags out of versions into being siblings of products

To post a comment you must log in.
348. By Tycho Andersen

whoops, don't commit pprint

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'simplestreams/util.py'
--- simplestreams/util.py 2014-03-25 22:10:17 +0000
+++ simplestreams/util.py 2014-06-09 21:20:41 +0000
@@ -190,7 +190,7 @@
190 if not ref:190 if not ref:
191 continue191 continue
192 value = data.get(key)192 value = data.get(key)
193 if value and isinstance(value, str):193 if value and isinstance(value, _STRING_TYPES):
194 data.update(ref[value])194 data.update(ref[value])
195 if delete:195 if delete:
196 del data[key]196 del data[key]
@@ -370,11 +370,11 @@
370 if k not in candidates:370 if k not in candidates:
371 continue371 continue
372 if k in updates:372 if k in updates:
373 if v != updates[k] or not isinstance(v, str):373 if v != updates[k] or not isinstance(v, _STRING_TYPES):
374 del updates[k]374 del updates[k]
375 candidates.remove(k)375 candidates.remove(k)
376 else:376 else:
377 if isinstance(v, str) and target.get(k, v) == v:377 if isinstance(v, _STRING_TYPES) and target.get(k, v) == v:
378 updates[k] = v378 updates[k] = v
379 else:379 else:
380 candidates.remove(k)380 candidates.remove(k)
@@ -397,6 +397,7 @@
397397
398 walk_products(ptree, cb_version=call_move_dups)398 walk_products(ptree, cb_version=call_move_dups)
399 walk_products(ptree, cb_product=call_move_dups)399 walk_products(ptree, cb_product=call_move_dups)
400 move_dups(ptree['products'], ptree)
400401
401402
402def assert_safe_path(path):403def assert_safe_path(path):
403404
=== modified file 'tests/unittests/test_util.py'
--- tests/unittests/test_util.py 2014-03-25 14:12:01 +0000
+++ tests/unittests/test_util.py 2014-06-09 21:20:41 +0000
@@ -143,8 +143,17 @@
143 def test_condense_1(self):143 def test_condense_1(self):
144 tree = {'products': {'P1': {'versions': {'1': {'A': 'B'},144 tree = {'products': {'P1': {'versions': {'1': {'A': 'B'},
145 '2': {'A': 'B'}}}}}145 '2': {'A': 'B'}}}}}
146 exp = {'products': {'P1': {'versions': {'1': {}, '2': {}},146 exp = {'A': 'B',
147 'A': 'B'}}}147 'products': {'P1': {'versions': {'1': {}, '2': {}}}}}
148
149 util.products_condense(tree)
150 self.assertEqual(tree, exp)
151
152 def test_condense_unicode(self):
153 tree = {'products': {'P1': {'versions': {'1': {'A': u'B'},
154 '2': {'A': u'B'}}}}}
155 exp = {'A': u'B',
156 'products': {'P1': {'versions': {'1': {}, '2': {}}}}}
148157
149 util.products_condense(tree)158 util.products_condense(tree)
150 self.assertEqual(tree, exp)159 self.assertEqual(tree, exp)
@@ -168,8 +177,8 @@
168 tree = {'products': {'P1': {'A': 'B',177 tree = {'products': {'P1': {'A': 'B',
169 'versions': {'1': {'A': 'B'},178 'versions': {'1': {'A': 'B'},
170 '2': {'A': 'B'}}}}}179 '2': {'A': 'B'}}}}}
171 exp = {'products': {'P1': {'versions': {'1': {}, '2': {}},180 exp = {'A': 'B',
172 'A': 'B'}}}181 'products': {'P1': {'versions': {'1': {}, '2': {}}}}}
173182
174 util.products_condense(tree)183 util.products_condense(tree)
175 self.assertEqual(tree, exp)184 self.assertEqual(tree, exp)
@@ -178,8 +187,8 @@
178 tree = {'products': {'P1': {'A': 'C',187 tree = {'products': {'P1': {'A': 'C',
179 'versions': {'1': {'A': 'B'},188 'versions': {'1': {'A': 'B'},
180 '2': {'A': 'B'}}}}}189 '2': {'A': 'B'}}}}}
181 exp = {'products': {'P1': {'A': 'C',190 exp = {'A': 'C',
182 'versions': {'1': {'A': 'B'},191 'products': {'P1': {'versions': {'1': {'A': 'B'},
183 '2': {'A': 'B'}}}}}192 '2': {'A': 'B'}}}}}
184193
185 util.products_condense(tree)194 util.products_condense(tree)

Subscribers

People subscribed via source and target branches

to all changes: