@@ -28,20 +28,27 @@ def set_output_directory(args):
28
28
return output_dir
29
29
30
30
31
- def _parse_file_list_file (file_list_path ):
32
- with open (file_list_path , "r" ) as f :
33
- # file_paths = [Path(file_path.strip()).resolve() for file_path in f.readlines()
34
- # if Path(file_path.strip()).is_file()]
35
- file_paths = [file_path .strip () for file_path in f .readlines ()]
36
- return file_paths
31
+ def expand_list_file (args ):
32
+ """
33
+ Expands the list of inputs by adding files from file lists and removing the file list.
37
34
35
+ Parameters
36
+ ----------
37
+ args argparse.Namespace
38
+ the arguments from the parser
38
39
39
- def expand_list_file (input ):
40
- file_list_inputs = [input_name for input_name in input if "file_list" in str (input_name )]
40
+ Returns
41
+ -------
42
+ the arguments with the modified input list
43
+
44
+ """
45
+ file_list_inputs = [input_name for input_name in args .input if "file_list" in input_name ]
41
46
for file_list_input in file_list_inputs :
42
- input .remove (file_list_input )
43
- input .extend (_parse_file_list_file (file_list_input ))
44
- return input
47
+ with open (file_list_input , "r" ) as f :
48
+ file_inputs = [input_name .strip () for input_name in f .readlines ()]
49
+ args .input .extend (file_inputs )
50
+ args .input .remove (file_list_input )
51
+ return args
45
52
46
53
47
54
def set_input_lists (args ):
@@ -63,9 +70,8 @@ def set_input_lists(args):
63
70
"""
64
71
65
72
input_paths = []
66
- expanded_input = expand_list_file (args .input )
67
- for input in expanded_input :
68
- input_path = Path (input ).resolve ()
73
+ for input_name in args .input :
74
+ input_path = Path (input_name ).resolve ()
69
75
if input_path .exists ():
70
76
if input_path .is_file ():
71
77
input_paths .append (input_path )
@@ -76,9 +82,11 @@ def set_input_lists(args):
76
82
]
77
83
input_paths .extend (input_files )
78
84
else :
79
- raise FileNotFoundError (f"Cannot find { input } . Please specify valid input file(s) or directories." )
85
+ raise FileNotFoundError (
86
+ f"Cannot find { input_name } . Please specify valid input file(s) or directories."
87
+ )
80
88
else :
81
- raise FileNotFoundError (f"Cannot find { input } " )
89
+ raise FileNotFoundError (f"Cannot find { input_name } " )
82
90
setattr (args , "input_paths" , list (set (input_paths )))
83
91
return args
84
92
0 commit comments