@@ -7,7 +7,8 @@ from qcrepocleaner.Ccdb import Ccdb
77import sys
88import re
99
10- def parseArgs ():
10+
11+ def parse_args ():
1112 """Parse the arguments passed to the script."""
1213 logging .info ("Parsing arguments" )
1314 parser = argparse .ArgumentParser (description = 'Move all objects in path to new-path' )
@@ -47,8 +48,11 @@ def run(args):
4748 ccdb = Ccdb (args .url )
4849
4950 nb_moved = 0
50- # we have to make sure we take all objects inside the provide path --> we add `/.*` at the end
51+ # we have to make sure we take all objects in the subfolders --> we add `/.*` at the end
5152 versions = ccdb .getVersionsList (args .path + "/.*" , "" , "" )
53+ # we also want to have all the versions at the root
54+ versions += ccdb .getVersionsList (args .path , "" , "" )
55+
5256 logging .info ("Here are the objects that are going to be moved: " )
5357 for v in versions :
5458 logging .info (v )
@@ -63,9 +67,9 @@ def run(args):
6367 exit (0 )
6468
6569 for v in versions :
66- logging .info (f"Ready to move { v } " )
6770 # here we need to make sure that we preserve the subdirectory structure and replace only the matching part
68- version_new_path = re .sub ("^" + args .path , args .new_path , v .path , count = 0 , flags = 0 )
71+ version_new_path = re .sub ("^" + args .path , args .new_path .rstrip ('/' ), v .path .rstrip ('/' ), count = 0 , flags = 0 )
72+ logging .info (f"Ready to move { v } to { version_new_path } " )
6973 if args .one_by_one :
7074 answer = input (" Continue? y/n\n " )
7175 if answer .lower () in ["y" , "yes" ]:
@@ -89,7 +93,7 @@ def main():
8993 prepare_main_logger ()
9094
9195 # Parse arguments
92- args = parseArgs ()
96+ args = parse_args ()
9397 logging .getLogger ().setLevel (int (args .log_level ))
9498
9599 run (args )
0 commit comments