class sunpy.util.datatype_factory_base.BasicRegistrationFactory(default_widget_type=None, additional_validation_functions=[], registry=None)[source] [edit on github]

Bases: object

Generalized 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.


dict – Dictionary mapping classes (key) to function (value) which validates input.


type – Class of the default widget. Defaults to None.


list of strings – List of function names that are valid validation functions.

  • default_widget_type (type, optional) –
  • additional_validation_functions (list of strings, optional) – List of strings corresponding to additional validation function names.


  • A valid validation function must be a classmethod of the registered widget and it must return True or False.

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] [edit on github]

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)[source] [edit on github]

Register a widget with the factory.

If validation_function is not specified, tests WidgetType for existence of any function in in the list self.validation_functions, which is a list of strings which must be callable class attribute

  • 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.
  • is_default (bool, optional) – Sets WidgetType to be the default widget.
unregister(WidgetType)[source] [edit on github]

Remove a widget from the factory’s registry.