pyworkflow.plugin module
- class pyworkflow.plugin.Domain[source]
Bases:
object
Class to represent the application domain. It will allow to specify new objects, protocols, viewers and wizards through the registration of new plugins.
- classmethod findClass(className)[source]
Find a class object given its name. The search will start with protocols and then with protocols.
- classmethod findViewers(className, environment)[source]
Find the available viewers in this Domain for this class.
- classmethod findWizards(protocol, environment)[source]
Find available wizards for this class, in this Domain.
- Parameters
protocol – Protocol instance for which wizards will be search.
environment – The environment name for wizards (e.g TKINTER)
:return A dict with the paramName and wizards for the protocol passed.
- classmethod getMapperDict()[source]
Return a dictionary that can be used with subclasses of Mapper to store/retrieve objects (including protocols) defined in this Domain.
- classmethod getPreferredViewers(className)[source]
Find and import the preferred viewers for this class.
- classmethod getProtocols()[source]
Return all Protocol subclasses from all plugins for this domain.
- static importFromPlugin(module, objects=None, errorMsg='', doRaise=False)[source]
This method try to import either a list of objects from the module/plugin or the whole module/plugin and returns what is imported if not fails. When the import fails (due to the plugin or the object is not found), it prints a common message + optional errorMsg; or it raise an error with the same message, if doRaise is True.
- Parameters
module – Module name to import
objects – Optional, string with objects to return present in module
errorMsg – Optional, extra error message to append to the main message.
doRaise – If True it will raise an exception instead of tolerating the import error
Usages:
# Import the whole plugin 'plugin1' as 'plug1' plug1 = importFromPlugin('plugin1') # Import a plugin's module pl1Cons = importFromPlugin('plug1.constants') # Import a single class from a plugin's module p1prot1 = importFromPlugin('plug1.protocols', 'prot1') # Import some classes from a plugin's module, # the returned tuple has the same length of the second argument pt1, pt2, ... = importFromPlugin('plugin1.protocols', ['pt1', 'pt2', ...])
- classmethod printInfo()[source]
Simple function (mainly for debugging) that prints basic information about this Domain.
- class pyworkflow.plugin.Plugin[source]
Bases:
object
- abstract classmethod defineBinaries(env)[source]
Define required binaries in the given Environment.
- classmethod getActiveVersion(home=None, versions=None)[source]
Returns the version of the binaries that are currently active. In the current implementation it will be inferred from the *_HOME variable, so it should contain the version number in it.
- classmethod getCondaActivationCmd()[source]
Returns the conda activation command with && at the end if defined otherwise empty
- abstract classmethod getEnviron()[source]
Set up the environment variables needed to launch programs.
- classmethod getHome(*paths)[source]
Return a path from the “home” of the package if the _homeVar is defined in the plugin.