FormatterFactory¶
-
class
lsst.daf.butler.
FormatterFactory
¶ Bases:
object
Factory for
Formatter
instances.Methods Summary
getFormatter
(entity, *args, **kwargs)Get a new formatter instance. getFormatterClass
(entity)Get the matching formatter class. getFormatterClassWithMatch
(entity)Get the matching formatter class along with the matching registry key. getFormatterWithMatch
(entity, *args, **kwargs)Get a new formatter instance along with the matching registry key. getLookupKeys
()Retrieve the look up keys for all the registry entries. registerFormatter
(type_, formatter)Register a Formatter
.registerFormatters
(config, *, universe)Bulk register formatters from a config. Methods Documentation
-
getFormatter
(entity, *args, **kwargs)¶ Get a new formatter instance.
Parameters: - entity :
DatasetRef
,DatasetType
,StorageClass
, orstr
Entity to use to determine the formatter to return.
StorageClass
will be used as a last resort ifDatasetRef
orDatasetType
instance is provided. Supports instrument override if aDatasetRef
is provided configured with aninstrument
value for the data ID.- args :
tuple
Positional arguments to use pass to the object constructor.
- kwargs :
dict
Keyword arguments to pass to object constructor.
Returns: - formatter :
Formatter
An instance of the registered formatter.
- entity :
-
getFormatterClass
(entity)¶ Get the matching formatter class.
Parameters: - entity :
DatasetRef
,DatasetType
,StorageClass
, orstr
Entity to use to determine the formatter to return.
StorageClass
will be used as a last resort ifDatasetRef
orDatasetType
instance is provided. Supports instrument override if aDatasetRef
is provided configured with aninstrument
value for the data ID.
Returns: - formatter :
type
The class of the registered formatter.
- entity :
-
getFormatterClassWithMatch
(entity)¶ Get the matching formatter class along with the matching registry key.
Parameters: - entity :
DatasetRef
,DatasetType
,StorageClass
, orstr
Entity to use to determine the formatter to return.
StorageClass
will be used as a last resort ifDatasetRef
orDatasetType
instance is provided. Supports instrument override if aDatasetRef
is provided configured with aninstrument
value for the data ID.
Returns: - entity :
-
getFormatterWithMatch
(entity, *args, **kwargs)¶ Get a new formatter instance along with the matching registry key.
Parameters: - entity :
DatasetRef
,DatasetType
,StorageClass
, orstr
Entity to use to determine the formatter to return.
StorageClass
will be used as a last resort ifDatasetRef
orDatasetType
instance is provided. Supports instrument override if aDatasetRef
is provided configured with aninstrument
value for the data ID.- args :
tuple
Positional arguments to use pass to the object constructor.
- kwargs :
dict
Keyword arguments to pass to object constructor.
Returns: - entity :
-
getLookupKeys
()¶ Retrieve the look up keys for all the registry entries.
Returns:
-
registerFormatter
(type_, formatter)¶ Register a
Formatter
.Parameters: - type_ :
LookupKey
,str
,StorageClass
orDatasetType
Type for which this formatter is to be used. If a
LookupKey
is not provided, one will be constructed from the supplied string or by using thename
property of the supplied entity.- formatter :
str
Identifies a
Formatter
subclass to use for reading and writing Datasets of this type.
Raises: - ValueError
Raised if the formatter does not name a valid formatter type.
- type_ :
-
registerFormatters
(config, *, universe)¶ Bulk register formatters from a config.
Parameters: - config :
Config
formatters
section of a configuration.- universe :
DimensionUniverse
, optional Set of all known dimensions, used to expand and validate any used in lookup keys.
Notes
The configuration can include one level of hierarchy where an instrument-specific section can be defined to override more general template specifications. This is represented in YAML using a key of form
instrument<name>
which can then define templates that will be returned if aDatasetRef
contains a matching instrument name in the data ID.The config is parsed using the function
processLookupConfigs
.- config :
-