Skip to content

Commit

Permalink
Fixes for unix passin for --inlist when using --inlist {cmd}
Browse files Browse the repository at this point in the history
  • Loading branch information
nkphysics committed Dec 25, 2022
1 parent 01eb2c7 commit a910cd9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion autonicer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 15 additions & 10 deletions autonicer/reprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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...")
2 changes: 1 addition & 1 deletion tests/test_autonicer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit a910cd9

Please sign in to comment.