Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong file extensions check in IC. #522

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/kbmod/standardizers/fits_standardizers/fits_standardizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,30 @@ def resolveFromPath(cls, tgt):
-----
FileNotFoundError - when file doesn't exist
"""
resources = {}
canProcess = False

# nasty hack, should do better extensions
fname = Path(tgt)
extensions = fname.suffixes
extensions = "".join(fname.suffixes)

# if the extensions are empty, we don't think it's a FITS file
if not extensions:
return False, {}
return False, resources

if extensions[-1] in cls.valid_extensions:
if extensions in cls.valid_extensions:
try:
hdulist = fits.open(tgt)
except OSError:
# OSError - file isn't a FITS file
# FileNotFoundError - bad file, let it raise
pass
else:
# otherwise it's a success!
resources = {"hdulist": hdulist}
canProcess = True

return canProcess, {"hdulist": hdulist}
return canProcess, resources

@classmethod
def resolveTarget(cls, tgt):
Expand Down
Loading