Plugin Systemο
Core Classesο
- class sloth.mmcif.plugins.Plugin[source]ο
Bases:
ABCAbstract base class for plugins that extend dot-notation functionality.
- abstract create_wrapper(target)[source]ο
Return a
PluginWrapper(or subclass) bound to target.- Return type:
- class sloth.mmcif.plugins.PluginWrapper[source]ο
Bases:
objectChainable wrapper returned when a plugin is accessed via dot-notation.
Calling the wrapper executes the plugin and returns
selfso that additional methods (defined by subclasses) can be chained:block._atom_site.validate().against(block._entity) value = block._atom_site.statistics().result
- class sloth.mmcif.plugins.FunctionPlugin[source]ο
Bases:
PluginAdapter that wraps a plain callable as a
Plugin.- create_wrapper(target)[source]ο
Return a
PluginWrapper(or subclass) bound to target.- Return type:
- class sloth.mmcif.plugins.PluginFactory[source]ο
Bases:
objectLightweight plugin registry keyed by name.
Plugins are registered with a name (the attribute that will appear via dot-notation access) and can be looked up or listed.
- register(name, plugin)[source]ο
Register a plugin.
- Parameters:
name (
str) β The dot-notation attribute name (e.g."validate").plugin β A
Plugininstance or a plain callable (auto-wrapped asFunctionPlugin).
- Return type:
- get_wrapper(name, target)[source]ο
Return a bound
PluginWrapperfor name, orNone.- Return type:
- Parameters:
name (str)
Model-Level Registrationο
All DataContainer subclasses
(Category,
DataBlock,
MMCIFDataContainer) expose
register(name, plugin) β see DataContainer.
Validation as a Plugin Exampleο
See sloth.mmcif.validator for ValidatorPlugin, CategoryValidator,
and concrete rule factories β the canonical example of the plugin system.