1616@MULTI_NETWORK .clicked (required = False )
1717@MULTI_SCHEME .clicked (required = False )
1818@MULTI_TAG .clicked (required = False )
19+ @click .option ('--save-tag' , type = str , default = None ,
20+ help = ("save object to a tag; requires that only one "
21+ + "object be specfied. Can also be used to rename "
22+ + "tagged objects. To append a tagged object without "
23+ + "a tag, use --add-tag \" \" " ))
1924def append (input_file , append_file , engine , cv , volume , network , scheme ,
20- tag ):
25+ tag , save_tag ):
2126 """Append objects from INPUT_FILE to another file.
2227 """
2328 storage = INPUT_FILE .get (input_file )
@@ -29,9 +34,26 @@ def append(input_file, append_file, engine, cv, volume, network, scheme,
2934 for arg , param in zip (args , params ):
3035 to_save .extend (param .get (storage , arg ))
3136
37+ to_save = [obj for obj in to_save if obj is not None ]
38+ if save_tag is not None and len (to_save ) != 1 :
39+ raise RuntimeError ("Can't identify the object to tag when saving "
40+ + str (len (to_save )) + " objects." )
41+
3242 for obj in to_save :
3343 output_storage .save (obj )
3444
45+ if tag and save_tag is None :
46+ save_tag = tag
47+
48+ if save_tag :
49+ output_storage .tags [save_tag ] = to_save [0 ]
50+
51+ # TO TEST
52+ # 1. append a tag in a new file: its tag comes with it
53+ # 2. rename a tagged object
54+ # 3. "untag" an object by not associating a tag in the new storage
55+ # 4. tag a previously untagged object
56+
3557 output_storage .close ()
3658
3759
0 commit comments