Skip to content

Commit

Permalink
ENH: Support single dataset checking from command line (#244)
Browse files Browse the repository at this point in the history
- Add support for passing a single JSON file to the dataset checker (in addition to a directory)
- Add error handling to let the user know if they gave a path that didn't find any JSON files to check
  • Loading branch information
Zhyrek committed Jun 28, 2023
1 parent d501e72 commit 0ea63a7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions espei/espei_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,16 @@ def main():
# if desired, check datasets and return
if args.check_datasets:
dataset_filenames = sorted(recursive_glob(args.check_datasets, '*.json'))

#if the path is a file, add that file to the list (test single dataset case!)
if(os.path.isfile(args.check_datasets)):
dataset_filenames.append(os.path.normpath(args.check_datasets))

#if there are no input files, warn the user they may have typed the wrong path
errors = []
if(len(dataset_filenames) == 0):
errors.append(OSError("No input .json files detected at "+str(os.path.normpath(args.check_datasets))+", is your path correct?"))

for dataset in dataset_filenames:
try:
load_datasets([dataset])
Expand Down

0 comments on commit 0ea63a7

Please sign in to comment.