Skip to content

Commit

Permalink
Add str(Formatter)
Browse files Browse the repository at this point in the history
  • Loading branch information
timj committed Aug 5, 2019
1 parent 2fc9e4c commit 1e6bbbd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/lsst/daf/butler/core/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def __init__(self, fileDescriptor):
raise TypeError("File descriptor must be a FileDescriptor")
self._fileDescriptor = fileDescriptor

def __str__(self):
return f"{self.name()}@{self.fileDescriptor.location.path}"

@property
def fileDescriptor(self):
"""FileDescriptor associated with this formatter
Expand Down
3 changes: 3 additions & 0 deletions tests/test_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ def testRegistry(self):
self.factory.registerFormatter(storageClassName, formatterTypeName)
f = self.factory.getFormatter(storageClassName, self.fileDescriptor)
self.assertIsFormatter(f)
self.assertEqual(f.name(), formatterTypeName)
self.assertIn(formatterTypeName, str(f))
self.assertIn(self.fileDescriptor.location.path, str(f))

fcls = self.factory.getFormatterClass(storageClassName)
self.assertIsFormatter(fcls)
Expand Down

0 comments on commit 1e6bbbd

Please sign in to comment.