Moved the generation of workflow list from dialogs.py to workflow.py, as
a step in the process of making command line options to the program.
This commit is contained in:
@@ -1,6 +1,48 @@
|
||||
|
||||
import gtk
|
||||
import logger
|
||||
import sys
|
||||
import os
|
||||
|
||||
def _workflow_classes(modname):
|
||||
"""Returns a list of all subclasses of Workflow in a given module"""
|
||||
workflow_classes = []
|
||||
|
||||
__import__('workflows.%s' % modname)
|
||||
module = sys.modules['workflows.%s' % modname]
|
||||
|
||||
d = module.__dict__
|
||||
for wf in d.values():
|
||||
try:
|
||||
if issubclass(wf, Workflow):
|
||||
workflow_classes.append(wf)
|
||||
except TypeError, e:
|
||||
pass
|
||||
return workflow_classes
|
||||
|
||||
def workflow_list():
|
||||
"""Returns a ListStore containing all new workflows"""
|
||||
retval = []
|
||||
|
||||
# List all .py files that can contain workflow classes
|
||||
wf_path = sys.modules['workflows'].__path__
|
||||
wf_files = []
|
||||
|
||||
for dir in wf_path:
|
||||
for fn in os.listdir(dir):
|
||||
if fn.endswith('.py') and ('#' not in fn):
|
||||
wf_files.append(fn[:-3])
|
||||
|
||||
# Try to load each file and look for Workflow derived classes
|
||||
for fn in wf_files:
|
||||
try:
|
||||
for wf in _workflow_classes(fn):
|
||||
retval.append(wf)
|
||||
except Exception, e:
|
||||
logger.log('warning', 'Cannot load workflow: %s' % fn)
|
||||
logger.log('warning', e)
|
||||
|
||||
return retval
|
||||
|
||||
class Workflow:
|
||||
"""Defines a workflow that contains a set of analysis stages.
|
||||
|
Reference in New Issue
Block a user