BasicRegistrationFactory#
- class sunpy.util.datatype_factory_base.BasicRegistrationFactory(
- default_widget_type=None,
- additional_validation_functions=[],
- registry=None,
Bases:
objectGeneralized registerable factory type.
Widgets (classes) can be registered with an instance of this class. Arguments to the factory’s
__call__method are then passed to a function specified by the registered factory, which validates the input and returns a instance of the class that best matches the inputs.- Parameters:
default_widget_type (
type, optional) – Class of the default widget. Defaults toNone.additional_validation_functions (
listofstr, optional) – List of strings corresponding to additional validation function names. Defaults tolist.registry (
dict, optional) – Dictionary mapping classes (key) to function (value) which validates input. Defaults toNone.
Notes
A valid validation function must be a classmethod of the registered widget and it must return a
bool.
Methods Summary
__call__(*args, **kwargs)Method for running the factory.
register(WidgetType[, validation_function, ...])Register a widget with the factory.
unregister(WidgetType)Remove a widget from the factory's registry.
Methods Documentation
- __call__(*args, **kwargs)[source]#
Method for running the factory.
Arguments args and kwargs are passed through to the validation function and to the constructor for the final type.
- register(
- WidgetType,
- validation_function=None,
- is_default=False,
Register a widget with the factory.
If
validation_functionis not specified, testsWidgetTypefor existence of any function in in the listself.validation_functions, which is a list of strings which must be callable class attribute.- Parameters:
WidgetType (
type) – Widget to register.validation_function (
function, optional) – Function to validate against. Defaults to None, which indicates that a classmethod in validation_functions is used. Defaults toNone.is_default (
bool, optional) – Sets WidgetType to be the default widget. Defaults toFalse.