From a910cd9eae197f48fcf0724c88b4206106e64fd5 Mon Sep 17 00:00:00 2001 From: Tsar Bomba Nick Date: Sun, 25 Dec 2022 00:19:55 -0600 Subject: [PATCH] Fixes for unix passin for --inlist when using --inlist {cmd} --- autonicer/__init__.py | 2 +- autonicer/reprocess.py | 25 +++++++++++++++---------- tests/test_autonicer.py | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/autonicer/__init__.py b/autonicer/__init__.py index c218c36..a6d96de 100644 --- a/autonicer/__init__.py +++ b/autonicer/__init__.py @@ -54,8 +54,8 @@ def run(args=None): "-inlist", "--inlist", help="Input .csv list with path to OBSID dirs or mpu7_cl.evt files for use with --reprocess and/or --checkcal", - type=str, default=None, + nargs="+", ) argp = p.parse_args(args) diff --git a/autonicer/reprocess.py b/autonicer/reprocess.py index db08136..ef5c56b 100644 --- a/autonicer/reprocess.py +++ b/autonicer/reprocess.py @@ -165,16 +165,21 @@ def inlist(argp): cwd = os.getcwd() curr_cals = autonicer.get_caldb_ver() try: - df = pd.read_csv(f"{argp.inlist}") - for i in df["Input"]: - path_sep = i.split("/xti/event_cl/") - os.chdir(path_sep[0]) - if argp.checkcal is True or argp.reprocess is True: - reprocess_check(argp, curr_cals) - os.chdir(cwd) + if len(argp.inlist) == 1: + df = pd.read_csv(f"{argp.inlist[0]}") + for i in df["Input"]: + path_sep = i.split("/xti/event_cl/") + os.chdir(path_sep[0]) + if argp.checkcal is True or argp.reprocess is True: + reprocess_check(argp, curr_cals) + os.chdir(cwd) + else: + raise FileNotFoundError except FileNotFoundError: - dirs = glob.glob(f"{argp.inlist}") + dirs = argp.inlist + if len(argp.inlist) == 1: + dirs = glob.glob(f"{argp.inlist[0]}") if len(dirs) != 0: for i in dirs: try: @@ -188,7 +193,7 @@ def inlist(argp): else: print(colored(f"DATASETS NOT FOUND", "red")) except pd.errors.ParserError: - print(colored(f"Unable to resolve --inlist {argp.inlist}", "red")) + print(colored(f"Unable to resolve --inlist {argp.inlist[0]}", "red")) except KeyError: - print(colored(f"{argp.inlist} format not readable", "red")) + print(colored(f"{argp.inlist[0]} format not readable", "red")) print("Format must be csv with Input column for inlist files...") diff --git a/tests/test_autonicer.py b/tests/test_autonicer.py index ee45e67..9598dea 100644 --- a/tests/test_autonicer.py +++ b/tests/test_autonicer.py @@ -286,7 +286,7 @@ def test_inlist_readin(capsys): os.chdir(f"{base_dir}") files = ["requirements.txt", "README.md"] for i in files: - autonicer.run(["--checkcal", f"--inlist={i}"]) + autonicer.run(["--checkcal", "--inlist", f"{i}"]) out, err = capsys.readouterr() pd_err = "Unable to resolve --inlist README.md" key_err = "requirements.txt format not readable"