本文整理汇总了Python中vistrails.core.modules.module_registry.get_module_registry函数的典型用法代码示例。如果您正苦于以下问题:Python get_module_registry函数的具体用法?Python get_module_registry怎么用?Python get_module_registry使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_module_registry函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, value):
self.value = value
if isinstance(self.value, basestring):
self.type = get_module_registry().get_descriptor_by_name(
'org.vistrails.vistrails.basic',
'String')
else: # isinstance(value, float):
self.type = get_module_registry().get_descriptor_by_name(
'org.vistrails.vistrails.basic',
'Float')
示例2: updateModule
def updateModule(self, module):
if self.updateLocked: return
self.check_need_save_changes()
self.module = module
self.confWidget.setUpdatesEnabled(False)
self.confWidget.setVisible(False)
self.confWidget.clear()
if module and self.controller:
registry = get_module_registry()
getter = registry.get_configuration_widget
widgetType = None
try:
widgetType = \
getter(module.package, module.name, module.namespace)
except ModuleRegistryException:
pass
if not widgetType:
widgetType = DefaultModuleConfigurationWidget
widget = widgetType(module, self.controller)
self.confWidget.setUpWidget(widget)
self.connect(widget, QtCore.SIGNAL("doneConfigure"),
self.configureDone)
self.connect(widget, QtCore.SIGNAL("stateChanged"),
self.stateChanged)
self.confWidget.setUpdatesEnabled(True)
self.confWidget.setVisible(True)
self.hasChanges = False
# we need to reset the title in case there were changes
self.setWindowTitle("Module Configuration")
示例3: register_self
def register_self(cls, **kwargs):
registry = get_module_registry()
def resolve_type(t):
if isinstance(t, tuple):
return registry.get_descriptor_by_name(*t).module
elif isinstance(t, type):
return t
else:
assert False, ("Unknown type " + str(type(t)))
registry.add_module(cls, **kwargs)
try:
ips = cls.input_ports
except AttributeError:
pass
else:
for (port_name, types) in ips:
registry.add_input_port(cls,
port_name,
list(resolve_type(t) for t in types))
try:
ops = cls.output_ports
except AttributeError:
pass
else:
for (port_name, types) in ops:
registry.add_output_port(cls,
port_name,
list(resolve_type(t) for t in types))
示例4: init
def init(self):
"""Initial setup of the Manager.
Discovers plots and variable loaders from packages and registers
notifications for packages loaded in the future.
"""
app = get_vistrails_application()
# dat_new_plot(plot: Plot)
app.create_notification('dat_new_plot')
# dat_removed_plot(plot: Plot)
app.create_notification('dat_removed_plot')
# dat_new_loader(loader: BaseVariableLoader)
app.create_notification('dat_new_loader')
# dat_removed_loader(loader: BaseVariableLoader)
app.create_notification('dat_removed_loader')
# dat_new_operation(loader: VariableOperation)
app.create_notification('dat_new_operation')
# dat_removed_operation(loader: VariableOperation)
app.create_notification('dat_removed_operation')
app.register_notification("reg_new_package", self.new_package)
app.register_notification("reg_deleted_package", self.deleted_package)
# Load the Plots and VariableLoaders from the packages
registry = get_module_registry()
for package in registry.package_list:
self.new_package(package.identifier)
示例5: collectParameterActions
def collectParameterActions(self):
""" collectParameterActions() -> list
Return a list of action lists corresponding to each dimension
"""
if not self.pipeline:
return None
reg = get_module_registry()
parameterValues = [[], [], [], []]
counts = self.label.getCounts()
for i in xrange(self.layout().count()):
pEditor = self.layout().itemAt(i).widget()
if pEditor and isinstance(pEditor, QParameterSetEditor):
for paramWidget in pEditor.paramWidgets:
editor = paramWidget.editor
interpolator = editor.stackedEditors.currentWidget()
paramInfo = paramWidget.param
dim = paramWidget.getDimension()
if dim in [0, 1, 2, 3]:
count = counts[dim]
values = interpolator.get_values(count)
if not values:
return None
pId = paramInfo.id
pType = paramInfo.dbtype
parentType = paramInfo.parent_dbtype
parentId = paramInfo.parent_id
function = self.pipeline.db_get_object(parentType,
parentId)
old_param = self.pipeline.db_get_object(pType,pId)
pName = old_param.name
pAlias = old_param.alias
pIdentifier = old_param.identifier
actions = []
tmp_id = -1L
for v in values:
getter = reg.get_descriptor_by_name
desc = getter(paramInfo.identifier,
paramInfo.type,
paramInfo.namespace)
if not isinstance(v, str):
str_value = desc.module.translate_to_string(v)
else:
str_value = v
new_param = ModuleParam(id=tmp_id,
pos=old_param.pos,
name=pName,
alias=pAlias,
val=str_value,
type=paramInfo.type,
identifier=pIdentifier
)
action_spec = ('change', old_param, new_param,
parentType, function.real_id)
action = vistrails.core.db.action.create_action([action_spec])
actions.append(action)
parameterValues[dim].append(actions)
tmp_id -= 1
return [zip(*p) for p in parameterValues]
示例6: __subclasscheck__
def __subclasscheck__(self, other):
if not issubclass(other, type):
raise TypeError
if not isinstance(other, ModuleClass):
return False
reg = get_module_registry()
return reg.is_descriptor_subclass(self.descriptor, other.descriptor)
示例7: __init__
def __init__(self, param, size, parent=None):
""" QParameterWidget(param: ParameterInfo, size: int, parent: QWidget)
-> QParameterWidget
"""
QtGui.QWidget.__init__(self, parent)
self.param = param
self.prevWidget = 0
hLayout = QtGui.QHBoxLayout(self)
hLayout.setMargin(0)
hLayout.setSpacing(0)
self.setLayout(hLayout)
hLayout.addSpacing(5+16+5)
self.label = QtGui.QLabel(param.spec.module)
self.label.setFixedWidth(50)
hLayout.addWidget(self.label)
registry = get_module_registry()
module = param.spec.descriptor.module
assert issubclass(module, Constant)
self.editor = QParameterEditor(param, size)
hLayout.addWidget(self.editor)
self.selector = QDimensionSelector()
self.connect(self.selector.radioButtons[4],
QtCore.SIGNAL('toggled(bool)'),
self.disableParameter)
hLayout.addWidget(self.selector)
示例8: get_module_registry
def get_module_registry():
global _registry
if _registry is None:
from vistrails.core.modules.module_registry import get_module_registry
_registry = get_module_registry()
return _registry
示例9: update_output_modules
def update_output_modules(self, *args, **kwargs):
# need to find all currently loaded output modes (need to
# check after modules are loaded and spin through registery)
# and display them here
reg = get_module_registry()
output_d = reg.get_descriptor_by_name(get_vistrails_basic_pkg_id(),
"OutputModule")
sublist = reg.get_descriptor_subclasses(output_d)
modes = {}
for d in sublist:
if hasattr(d.module, '_output_modes_dict'):
for mode_type, (mode, _) in (d.module._output_modes_dict
.iteritems()):
modes[mode_type] = mode
found_modes = set()
for mode_type, mode in modes.iteritems():
found_modes.add(mode_type)
if mode_type not in self.mode_widgets:
mode_config = None
output_settings = self.persistent_config.outputDefaultSettings
if output_settings.has(mode_type):
mode_config = getattr(output_settings, mode_type)
widget = OutputModeConfigurationWidget(mode, mode_config)
widget.fieldChanged.connect(self.field_was_changed)
self.inner_layout.addWidget(widget)
self.mode_widgets[mode_type] = widget
for mode_type, widget in self.mode_widgets.items():
if mode_type not in found_modes:
self.inner_layout.removeWidget(self.mode_widgets[mode_type])
del self.mode_widgets[mode_type]
示例10: can_convert
def can_convert(cls, sub_descs, super_descs):
from vistrails.core.modules.module_registry import get_module_registry
from vistrails.core.system import get_vistrails_basic_pkg_id
reg = get_module_registry()
basic_pkg = get_vistrails_basic_pkg_id()
variant_desc = reg.get_descriptor_by_name(basic_pkg, 'Variant')
desc = reg.get_descriptor(cls)
def check_types(sub_descs, super_descs):
for (sub_desc, super_desc) in izip(sub_descs, super_descs):
if (sub_desc == variant_desc or super_desc == variant_desc):
continue
if not reg.is_descriptor_subclass(sub_desc, super_desc):
return False
return True
in_port = reg.get_port_spec_from_descriptor(
desc,
'in_value', 'input')
if (len(sub_descs) != len(in_port.descriptors()) or
not check_types(sub_descs, in_port.descriptors())):
return False
out_port = reg.get_port_spec_from_descriptor(
desc,
'out_value', 'output')
if (len(out_port.descriptors()) != len(super_descs)
or not check_types(out_port.descriptors(), super_descs)):
return False
return True
示例11: handle_module_upgrade_request
def handle_module_upgrade_request(controller, module_id, pipeline):
old_module = pipeline.modules[module_id]
if old_module.name == "JSONFile" and old_module.version != "0.1.5" and old_module.namespace == "read":
from vistrails.core.db.action import create_action
from vistrails.core.modules.module_registry import get_module_registry
from .read.read_json import JSONObject
reg = get_module_registry()
new_desc = reg.get_descriptor(JSONObject)
new_module = controller.create_module_from_descriptor(new_desc, old_module.location.x, old_module.location.y)
actions = UpgradeWorkflowHandler.replace_generic(controller, pipeline, old_module, new_module)
new_function = controller.create_function(new_module, "key_name", ["_key"])
actions.append(create_action([("add", new_function, "module", new_module.id)]))
return actions
module_remap = {
"read|csv|CSVFile": [(None, "0.1.1", "read|CSVFile", {"src_port_remap": {"self": "value"}})],
"read|numpy|NumPyArray": [(None, "0.1.1", "read|NumPyArray", {"src_port_remap": {"self": "value"}})],
"read|CSVFile": [("0.1.1", "0.1.2", None, {"src_port_remap": {"self": "value"}}), ("0.1.3", "0.1.5", None, {})],
"read|NumPyArray": [("0.1.1", "0.1.2", None, {"src_port_remap": {"self": "value"}})],
"read|ExcelSpreadsheet": [
("0.1.1", "0.1.2", None, {"src_port_remap": {"self": "value"}}),
("0.1.3", "0.1.4", None, {}),
],
"read|JSONFile": [(None, "0.1.5", "read|JSONObject")],
}
return UpgradeWorkflowHandler.remap_module(controller, module_id, pipeline, module_remap)
示例12: find_descriptor
def find_descriptor(controller, pipeline, module_id, desired_version=''):
reg = get_module_registry()
get_descriptor = reg.get_descriptor_by_name
pm = get_package_manager()
invalid_module = pipeline.modules[module_id]
mpkg, mname, mnamespace, mid = (invalid_module.package,
invalid_module.name,
invalid_module.namespace,
invalid_module.id)
pkg = pm.get_package(mpkg)
desired_version = ''
d = None
# don't check for abstraction/subworkflow since the old module
# could be a subworkflow
if reg.has_abs_upgrade(*invalid_module.descriptor_info):
return reg.get_abs_upgrade(*invalid_module.descriptor_info)
try:
try:
d = get_descriptor(mpkg, mname, mnamespace, '', desired_version)
except MissingModule, e:
r = None
if pkg.can_handle_missing_modules():
r = pkg.handle_missing_module(controller, module_id,
pipeline)
d = get_descriptor(mpkg, mname, mnamespace, '',
desired_version)
if not r:
raise e
except MissingModule, e:
return None
示例13: updateController
def updateController(self, controller):
""" updateController(controller: VistrailController) -> None
Construct input forms for a controller's variables
"""
# we shouldn't do this whenver the controller changes...
if self.controller != controller:
self.controller = controller
if self.updateLocked: return
self.vWidget.clear()
if controller:
reg = module_registry.get_module_registry()
for var in [v for v in controller.vistrail.vistrail_vars]:
try:
descriptor = reg.get_descriptor_by_name(var.package,
var.module,
var.namespace)
except module_registry.ModuleRegistryException:
debug.critical("Missing Module Descriptor for vistrail"
" variable %s\nPackage: %s\nType: %s"
"\nNamespace: %s" % \
(var.name, var.package, var.module,
var.namespace))
continue
self.vWidget.addVariable(var.uuid, var.name, descriptor,
var.value)
self.vWidget.showPromptByChildren()
else:
self.vWidget.showPrompt(False)
示例14: check_port_spec
def check_port_spec(module, port_name, port_type, descriptor=None,
sigstring=None):
basic_pkg = get_vistrails_basic_pkg_id()
reg = get_module_registry()
found = False
try:
if descriptor is not None:
s = reg.get_port_spec_from_descriptor(descriptor, port_name,
port_type)
found = True
spec_tuples = parse_port_spec_string(sigstring, basic_pkg)
for i in xrange(len(spec_tuples)):
spec_tuple = spec_tuples[i]
port_pkg = reg.get_package_by_name(spec_tuple[0])
if port_pkg.identifier != spec_tuple[0]:
# we have an old identifier
spec_tuples[i] = (port_pkg.identifier,) + spec_tuple[1:]
sigstring = create_port_spec_string(spec_tuples)
# sigstring = expand_port_spec_string(sigstring, basic_pkg)
if s.sigstring != sigstring:
msg = ('%s port "%s" of module "%s" exists, but '
'signatures differ "%s" != "%s"') % \
(port_type.capitalize(), port_name, module.name,
s.sigstring, sigstring)
raise UpgradeWorkflowError(msg, module, port_name, port_type)
except MissingPort:
pass
if not found and \
not module.has_portSpec_with_name((port_name, port_type)):
msg = '%s port "%s" of module "%s" does not exist.' % \
(port_type.capitalize(), port_name, module.name)
raise UpgradeWorkflowError(msg, module, port_name, port_type)
示例15: inspect_spreadsheet_cells
def inspect_spreadsheet_cells(self, pipeline):
""" inspect_spreadsheet_cells(pipeline: Pipeline) -> None
Inspect the pipeline to see how many cells is needed
"""
registry = get_module_registry()
self.spreadsheet_cells = []
if not pipeline: return
def find_spreadsheet_cells(pipeline, root_id=None):
if root_id is None:
root_id = []
# Sometimes we run without the spreadsheet!
spreadsheet_pkg = \
'%s.spreadsheet' % get_vistrails_default_pkg_prefix()
if registry.has_module(spreadsheet_pkg, 'SpreadsheetCell'):
# First pass to check cells types
cellType = \
registry.get_descriptor_by_name(spreadsheet_pkg,
'SpreadsheetCell').module
for mId, module in pipeline.modules.iteritems():
desc = registry.get_descriptor_by_name(module.package,
module.name,
module.namespace)
if issubclass(desc.module, cellType):
self.spreadsheet_cells.append(root_id + [mId])
for subworkflow_id in self.find_subworkflows(pipeline):
subworkflow = pipeline.modules[subworkflow_id]
if subworkflow.pipeline is not None:
find_spreadsheet_cells(subworkflow.pipeline,
root_id + [subworkflow_id])
find_spreadsheet_cells(pipeline)