MappingFactory¶
- class lsst.daf.butler.mapping_factory.MappingFactory(refType: type)¶
Bases:
object
Register the mapping of some key to a python type and retrieve instances.
Enables instances of these classes to be retrieved from the factory later. The class can be specified as an object, class or string. If the key is an object it is converted to a string by accessing a
name
attribute.- Parameters:
Methods Summary
getClassFromRegistry
(targetClasses)Get the matching class stored in the registry.
getClassFromRegistryWithMatch
(targetClasses)Get the class stored in the registry along with the matching key.
getFromRegistry
(targetClasses, *args, **kwargs)Get a new instance of the object stored in the registry.
getFromRegistryWithMatch
(targetClasses, ...)Get a new instance of the registry object along with matching key.
Retrieve the look up keys for all the registry entries.
placeInRegistry
(registryKey, typeName[, ...])Register a class name with the associated type.
Methods Documentation
- getClassFromRegistry(targetClasses: Iterable[Any]) type ¶
Get the matching class stored in the registry.
- Parameters:
- Returns:
- cls
type
Class stored in registry associated with the first matching target class.
- cls
- Raises:
- KeyError
Raised if none of the supplied target classes match an item in the registry.
- getClassFromRegistryWithMatch(targetClasses: Iterable[Any]) tuple[lsst.daf.butler._config_support.LookupKey, type, dict[Any, Any]] ¶
Get the class stored in the registry along with the matching key.
- Parameters:
- Returns:
- Raises:
- KeyError
Raised if none of the supplied target classes match an item in the registry.
- getFromRegistry(targetClasses: Iterable[Any], *args: Any, **kwargs: Any) Any ¶
Get a new instance of the object stored in the registry.
- Parameters:
- Returns:
- instance
object
Instance of class stored in registry associated with the first matching target class.
- instance
- Raises:
- KeyError
Raised if none of the supplied target classes match an item in the registry.
- getFromRegistryWithMatch(targetClasses: Iterable[Any], *args: Any, **kwargs: Any) tuple[lsst.daf.butler._config_support.LookupKey, Any] ¶
Get a new instance of the registry object along with matching key.
- Parameters:
- Returns:
- matchKey
LookupKey
The key that resulted in the successful match.
- instance
object
Instance of class stored in registry associated with the first matching target class.
- matchKey
- Raises:
- KeyError
Raised if none of the supplied target classes match an item in the registry.
- getLookupKeys() set[lsst.daf.butler._config_support.LookupKey] ¶
Retrieve the look up keys for all the registry entries.
- Returns:
- keys
set
ofLookupKey
The keys available for matching in the registry.
- keys
- placeInRegistry(registryKey: Any, typeName: str | type, overwrite: bool = False, **kwargs: Any) None ¶
Register a class name with the associated type.
- Parameters:
- registryKey
LookupKey
,str
or object withname
attribute Item to associate with the provided type.
- typeName
str
or Python type Identifies a class to associate with the provided key.
- overwrite
bool
, optional If
True
, an existing entry will be overwritten. This option is expected to be used to simplify test suites. Default isFalse
.- **kwargs
Keyword arguments to always pass to object constructor when retrieved.
- registryKey
- Raises:
- KeyError
Raised if item is already registered and has different value and
overwrite
isFalse
.