exopy.utils.plugin_tools module¶
Useful tools to avoid code duplication when writing plugins.
-
class
exopy.utils.plugin_tools.
HasPreferencesPlugin
[source]¶ Bases:
enaml.workbench.plugin.Plugin
Base class for plugin using preferences.
Simply defines the most basic preferences system inherited from HasPrefAtom. Preferences are automatically queried and saved using the exopy.app.preferences plugin.
-
update_members_from_preferences
(parameters)¶ Use the string values given in the parameters to update the members
This function will call itself on any tagged HasPrefAtom member.
-
preferences_from_members
()¶ Get the members values as string to store them in .ini files.
-
-
exopy.utils.plugin_tools.
make_handler
(id, method_name)[source]¶ Generate a generic handler calling a plugin method.
-
exopy.utils.plugin_tools.
make_extension_validator
(base_cls, fn_names=(), attributes='description')[source]¶ Create an extension validation function checking that key methods were overridden and attributes values provided.
- Parameters
base_cls (
type
) – Base class from which the contribution should inherit.fn_names (
iterable[unicode]
, optional) – Names of the function the extensions must override.attributes (
iterable[unicode]
, optional) – Names of the attributes the extension should provide values for.
- Returns
validator – Function that can be used to validate an extension contribution.
- Return type
callable
-
class
exopy.utils.plugin_tools.
ClassTuple
(vals)[source]¶ Bases:
tuple
Special tuple meant to hold classes.
Provides an smart constructor and a nice str representation.
-
class
exopy.utils.plugin_tools.
BaseCollector
[source]¶ Bases:
atom.atom.Atom
Base class for automating extension collection.
-
workbench
¶ Reference to the application workbench.
-
point
¶ Id of the extension point to observe.
-
ext_class
¶ Expected class(es) of the object generated by the extension.
-
contributions
¶ Dictionary storing the consributiosn of the observed extension point. This should not be altered by user code. This is never modified in place so user code will get reliable notifications when observing it.
-
-
class
exopy.utils.plugin_tools.
ExtensionsCollector
[source]¶ Bases:
exopy.utils.plugin_tools.BaseCollector
Convenience class collecting an extension point contribution.
This class can be used on any extension point to which extensions contribute instances of a specific class. Those object should always have an id member.
-
validate_ext
¶ Callable to use to ensure that the provide extension does fit. Should take the proposed contribution as single argument and return a bool indicating the result of the test, and a message explaining what went wrong (or an empty string if test passed).
-
-
class
exopy.utils.plugin_tools.
DeclaratorsCollector
[source]¶ Bases:
exopy.utils.plugin_tools.BaseCollector
Class registering Declarator contributed to an extension point.
This class can be used on any extension point to which extensions contribute Declarator.