plugin module#
Defines the plugin system for registering xsnowDatset methods.
This is used in xsnow to keep the xsnowDataset class definition tidy and register class methods from other modules. It can also be used to register completely custom functions that do not ship with this package.
- xsnow.plugin.register_xsnowDataset_method(func=None, *, name=None)#
Decorator to attach a free function as a method on xsnowDataset.
The decorated function must take an xsnowDataset object as its first argument, followed by any other parameters. When the method is called on an xsnowDataset instance, the instance itself is automatically passed as this first argument.
Parameters:#
func (Callable): The function to be registered name (str), optional: An alias for the registered method. Defaults to the function name.
Examples:#
from xsnow.extensions import register_xsnowDataset_method @register_xsnowDataset_method def mytool(self, …): …
@register_xsnowDataset_method(name=”alias”) def mytool(self, …): …
# Usage: >>> import xsnow >>> ds = xsnow.read(‘path/to/data’) >>> ds.mytool(…)
Returns:#
- :
Callable: The original, unmodified function.
- xsnow.plugin.list_registered_methods()#
Return a copy of the registered extension methods (for docs/CLI).
- Return type:
Dict[str,Callable]