@@ -26,27 +26,37 @@ def main():
2626 mandatory_arguments .add_argument ("--packages-home" ,
2727 dest = "packages_home_dir" ,
2828 metavar = 'repository directory' ,
29- required = True ,
29+ required = False ,
3030 help = 'copy found artifacts here' )
3131
32- parser .add_argument ("base_dirs " ,
32+ parser .add_argument ("items " ,
3333 metavar = 'base directory to search or archive file' ,
3434 nargs = argparse .REMAINDER ,
3535 help = 'base directory to search for artifacts or archive file' )
3636
3737 arguments = parser .parse_args ()
3838
39- if arguments .base_dirs is None or len (arguments .base_dirs ) == 0 :
39+ if arguments .items is None or len (arguments .items ) == 0 :
4040 parser .print_usage ()
41- raise Exception ("missing base directories" )
42-
43- for base_dir in arguments .base_dirs :
44- if os .path .isfile (base_dir ):
45- artifacts .copy_package (base_dir , arguments .packages_home_dir )
46- elif os .path .isdir (base_dir ):
47- print ("-------------- searching base dir: " , base_dir , " -----------------" )
48- for archive in glob .glob (os .path .join (base_dir , "**" , "*.tar.gz" ), recursive = True ):
49- artifacts .copy_package (archive , arguments .packages_home_dir )
41+ raise Exception ("missing item list" )
42+ else :
43+ if arguments .packages_home_dir is not None :
44+ repository = arguments .packages_home_dir
45+ else :
46+ repository = arguments .items [len (arguments .items ) - 1 ]
47+ arguments .items .pop ()
48+
49+ assert os .path .isdir (repository ), "{} is not a directory." .format (repository )
50+
51+ for item in arguments .items :
52+ if os .path .isfile (item ):
53+ artifacts .copy_package (item , repository )
54+ elif os .path .isdir (item ):
55+ print ("-------------- searching base dir: " , item , " -----------------" )
56+ for archive in glob .glob (os .path .join (item , "**" , "*.tar.gz" ), recursive = True ):
57+ artifacts .copy_package (archive , repository )
58+ else :
59+ raise AssertionError ("'{}' is neither a file nor a directory." .format (item ))
5060
5161 except AssertionError as err :
5262 print ("error: {} failed. {}" .format (parser .prog , err ))
0 commit comments