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

DM-15455: Support trailing text in file template format string #75

Merged
merged 2 commits into from
Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions python/lsst/daf/butler/core/fileTemplates.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ def format(self, ref):
if field_name == "component":
usedComponent = True

if format_spec is None:
output = output + literal
continue

if "?" in format_spec:
optional = True
# Remove the non-standard character from the spec
Expand Down
8 changes: 4 additions & 4 deletions python/lsst/daf/butler/registries/sqlRegistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ def addDataset(self, datasetType, dataId, run, producer=None):

Parameters
----------
datasetType : `str`
Name of a `DatasetType`.
datasetType : `DatasetType`
Type of the Dataset.
dataId : `dict`
A `dict` of `DataUnit` link name, value pairs that label the
`DatasetRef` within a collection.
Expand Down Expand Up @@ -381,8 +381,8 @@ def addDataset(self, datasetType, dataId, run, producer=None):
# Then again, it is undoubtedly not the only place where
# this problem occurs. Needs some serious thought.
if self.find(run.collection, datasetType, dataId) is not None:
raise ValueError("A dataset with id: {} already exists in collection {}".format(
dataId, run.collection))
raise ValueError("A dataset of type {} with id: {} already exists in collection {}".format(
datasetType, dataId, run.collection))
datasetTable = self._schema.tables["Dataset"]
datasetRef = None
# TODO add producer
Expand Down
2 changes: 2 additions & 0 deletions tests/test_sqlRegistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ def testDataset(self):
outRef = registry.getDataset(ref.id)
self.assertIsNotNone(ref.id)
self.assertEqual(ref, outRef)
with self.assertRaises(ValueError):
ref = registry.addDataset(datasetType, dataId={"camera": "DummyCam"}, run=run)

def testComponents(self):
registry = Registry.fromConfig(self.butlerConfig, create=True)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def testBasic(self):
self.assertTemplate(tmplstr,
"calexp/00052/U",
self.makeDatasetRef("calexp"))
tmplstr = "{datasetType}/{visit:05d}/{filter}-trail"
self.assertTemplate(tmplstr,
"calexp/00052/U-trail",
self.makeDatasetRef("calexp"))

def testOptional(self):
"""Optional units in templates."""
Expand Down