Skip to content

Commit

Permalink
silently allow .gz and .fz extesion when mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
n8pease committed Nov 11, 2016
1 parent 8182a57 commit 5f6d8c0
Show file tree
Hide file tree
Showing 5 changed files with 36,523 additions and 3 deletions.
16 changes: 13 additions & 3 deletions python/lsst/obs/base/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,19 @@ def map(self, mapper, dataId, write=False):
if not os.path.isabs(path):
path = os.path.join(self.root, path)
if not write:
newPath = mapper._parentSearch(path)
if newPath:
path = newPath
for ext in (None, '.gz', '.fz'):
if path.endswith(ext):
continue # if the path already ends with the extension
extPath = path + ext if ext else path
newPath = mapper._parentSearch(extPath)
if newPath:
path = newPath
break
# This allows mapped files to be compressed, ending in .gz, without any indication from the
# policy that the file should be compressed. This allows repositories to contain a combination
# of comporessed and not-compressed files.
# If needed we can add a policy flag to allow compressed files or not, and perhaps a list of
# allowed extensions that may exist at the end of the template.
assert path, "Fully-qualified filename is empty."

addFunc = "add_" + self.datasetType # Name of method for additionalData
Expand Down
12 changes: 12 additions & 0 deletions tests/MinMapper2.paf
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ images: {
persistable: "ImageF"
tables: raw
}
someGz: {
template: "gz/bar-%(ccd)02d.fits" # the file will end in ...fits.gz but butler will still find it.
python: "lsst.afw.image.ExposureF"
persistable: "ExposureF"
tables: raw
}
someFz: {
template: "fz/bar-%(ccd)02d.fits" # the file will end in ...fits.fz but butler will still find it.
python: "lsst.afw.image.ExposureF"
persistable: "ExposureF"
tables: raw
}
}
calibrations: {
flat: {
Expand Down

0 comments on commit 5f6d8c0

Please sign in to comment.