6095: Stop demoting OrderedDicts to dicts in arv-copy.
authorBrett Smith <brett@curoverse.com>
Mon, 17 Aug 2015 21:34:09 +0000 (17:34 -0400)
committerBrett Smith <brett@curoverse.com>
Mon, 17 Aug 2015 21:34:54 +0000 (17:34 -0400)
History: first there was 79564b0ac7d03327cc351bbd6df544ab1f776380.
This preserved the order of copied pipeline templates, but that's in
part because it stopped recursing through those templates.
1b8caff3ad598744e4a0379b01fc95ca4838caa0 fixed the recursion, but then
started losing the order again.  This retains the order by ensuring we
copy OrderedDicts as OrderedDicts.

Refs #6095, #7001.

sdk/python/arvados/commands/arv_copy.py

index f728b2c59142359bf66855ec530dd82bfb483507..c1ee156bcca0ea2410fa86f9d764c6c4f54a6d32 100755 (executable)
@@ -330,9 +330,10 @@ def copy_collections(obj, src, dst, args):
         obj = arvados.util.collection_uuid_pattern.sub(copy_collection_fn, obj)
         return obj
     elif isinstance(obj, dict):
-        return {v: copy_collections(obj[v], src, dst, args) for v in obj}
+        return type(v)((v, copy_collections(obj[v], src, dst, args))
+                       for v in obj)
     elif isinstance(obj, list):
-        return [copy_collections(v, src, dst, args) for v in obj]
+        return type(v)(copy_collections(v, src, dst, args) for v in obj)
     return obj
 
 def migrate_jobspec(jobspec, src, dst, dst_repo, args):