2
"""Contains all processes """
3
__docformat__ = "restructuredtext"
5
from mrv.automation.process import ProcessBase
9
def parseProcessesFromPackage( importBase, packageFile ):
10
"""Parse all processes from the given package's sub-modules and add them to main
11
processes module to make them available to the workflow system
13
:param importBase: Something like: parentPackage.subpackage.mypackage, of your processes package
14
:param packageFile: the pointing to your processes package, usually __file__ of your package
16
isProcess = lambda cls: hasattr( cls, 'mro' ) and ProcessBase in cls.mro()
17
processes = util.getPackageClasses( importBase, packageFile, predicate = isProcess )
20
for pcls in processes:
21
gd[pcls.__name__] = pcls
22
# END for each process
24
def addProcesses( *args ):
25
"""Add the given process classes to the list of known process types. They will be regeistered
26
with their name obtained by str( processCls ).
27
Workflows loaded from files will have access to the processes in this package
29
:param args: process classes to be registered to this module."""
32
if ProcessBase not in pcls.mro():
33
raise TypeError( "%r does not support the process interface" % pcls )
35
gd[pcls.__name__] = pcls