Plugin Systemο
Core Classesο
- class sloth.mmcif.plugins.PluginFactory[source]ο
Bases:
objectInstance-level plugin registry for extending dot-notation access.
Plugins are registered with a name (the attribute that will appear on the data object) and a scope that determines which hierarchy level exposes the plugin:
PluginScope.CATEGORYβ available onCategoryobjectsPluginScope.BLOCKβ available onDataBlockobjectsPluginScope.CONTAINERβ available onMMCIFDataContainerobjects
- register(name, plugin, *, scope)[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).scope (
PluginScope) β APluginScopemember.
- Return type:
- get_wrapper(name, target, scope)[source]ο
Return a bound
PluginWrapperfor name, orNone.- Return type:
- Parameters:
name (str)
scope (PluginScope)
- 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
Validation as a Plugin Exampleο
See the validation implementation in:
sloth.mmcif.validatorforValidatorPluginandCategoryValidatorsloth.mmcif.rulesfor concrete validator implementations