Skip to content

Commit 54077fa

Browse files
committed
Fix: merged --infolder with the default case file
1 parent 6a6cb48 commit 54077fa

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

jureptool/src/main.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,6 @@ def main():
10261026
# Parse arguments
10271027
parser = argparse.ArgumentParser(description="JuRepTool")
10281028
parser.add_argument("file", nargs="*", default="", help="File including list of running and recently-finished jobs or JSON file of a job")
1029-
parser.add_argument('--infolder', nargs="+", default="", help="Folder(s) with all the .json to be processed (alternative to file option)")
10301029
parser.add_argument("--daemon", default=False, action="store_true" , help="Run as a 'daemon', i.e., in an infinite loop")
10311030
parser.add_argument("--demo", default=False, action="store_true" , help="Run in 'demo' mode (hide usernames, project id and job names)")
10321031
parser.add_argument("--nomove", default=False, action="store_true" , help="Don't copy files to final location")
@@ -1045,9 +1044,6 @@ def main():
10451044
parser.add_argument("--remail", default="", help="Receiver email to use in case of errors (default: None)")
10461045
args = parser.parse_args()
10471046

1048-
if not args.file and not args.infolder:
1049-
parser.error("Either file(s) or --infolder must be specified")
1050-
10511047
# Parsing configuration
10521048
config = {}
10531049
# Report appearance
@@ -1061,18 +1057,22 @@ def main():
10611057
# config['appearance']['plotly_js'] = args.plotlyjs
10621058

10631059
# Configuration
1064-
config['file'] = []
1065-
1066-
if args.infolder:
1067-
for folder in args.infolder:
1068-
if not os.path.isdir(folder):
1069-
raise ValueError(f"--infolder must be a valid directory: {folder}")
1070-
config['file'] += [os.path.join(folder, fname) for fname in os.listdir(folder) if fname.endswith('.json')]
1071-
config['json'] = True
1072-
else:
1073-
for file in args.file:
1074-
config['file'] += glob.glob(file)
1060+
config['file'] = set()
1061+
# changed to a set to remove duplicate, edgecase where
1062+
# input : fileA folderB(fileA,fileB) -> config['file']= fileA, fileA, fileB
1063+
1064+
if args.file:
1065+
for element in args.file:
1066+
if os.path.isfile(element):
1067+
config['file'].update(glob.glob(element))
1068+
elif os.path.isdir(element):
1069+
config['file'].update(os.path.join(element, fname) for fname in os.listdir(element) if fname.endswith('.json'))
1070+
else:
1071+
raise FileNotFoundError(f"File not found: {element}")
10751072
config['json'] = all([_.endswith('json') for _ in config['file']])
1073+
else:
1074+
parser.print_help()
1075+
raise FileNotFoundError(f"Config {args.config} does not exist")
10761076

10771077
config['demo'] = args.demo
10781078
config['html'] = not args.nohtml

0 commit comments

Comments
 (0)