コード例 #1
0
ファイル: init.py プロジェクト: AnyarInc/VisTrails
def createAllModules(g):
    """ createAllModules(g: ClassTree) -> None
    Traverse the VTK class tree and add all modules into the module registry
    
    """
    if tuple(vtk.vtkVersion().GetVTKVersion().split('.')) < ('5', '7', '0'):
        assert len(g.tree[0]) == 1
        base = g.tree[0][0]
        assert base.name == 'vtkObjectBase'
    
    vtkObjectBase = new_module(vtkBaseModule, 'vtkObjectBase')
    vtkObjectBase.vtkClass = vtk.vtkObjectBase
    registry = get_module_registry()
    registry.add_module(vtkObjectBase)
    if tuple(vtk.vtkVersion().GetVTKVersion().split('.')) < ('5', '7', '0'):
        for child in base.children:
            if child.name in disallowed_classes:
                continue
            createModule(vtkObjectBase, child)
    else:
        for base in g.tree[0]:
            for child in base.children:
                if child.name in disallowed_classes:
                    continue
                createModule(vtkObjectBase, child)
コード例 #2
0
    def _add_new_api(self, api):
        self.highlighted_api = api
        mashups = self.data_source.mashups_by_api(api)
        for mashup in mashups:
            mashup['related_mashups'] = (self.data_source.apis_by_mashup(mashup))
        if len(mashups) > 0:
            self.related_mashups = mashups
            self._show_related_apis()
        manager = core.packagemanager.get_package_manager()
        reg = core.modules.module_registry.get_module_registry()
        package = manager.get_package("edu.cmu.sv.components", "1.0.0")
        core.modules.module_registry.set_current_package(package)

        if (api["protocols"] == "SOAP" and api["wsdl"] != ""):
            s = Service(api["wsdl"])
            add_new_service(s, api["wsdl"])
        else:
            new_module = vistrails_module.new_module(Module, get_api_name(api))
            reg.add_module(new_module)
    
            reg.add_input_port(new_module, "value1",
                         (core.modules.basic_modules.String, 'the first argument'))
            reg.add_input_port(new_module, "value2",
                         (core.modules.basic_modules.String, 'the second argument'))
            reg.add_output_port(new_module, "value",
                          (core.modules.basic_modules.String, 'the result'))
コード例 #3
0
def createAllModules(g):
    """ createAllModules(g: ClassTree) -> None
    Traverse the VTK class tree and add all modules into the module registry
    
    """
    if tuple(vtk.vtkVersion().GetVTKVersion().split('.')) < ('5', '7', '0'):
        assert len(g.tree[0]) == 1
        base = g.tree[0][0]
        assert base.name == 'vtkObjectBase'

    vtkObjectBase = new_module(vtkBaseModule, 'vtkObjectBase')
    vtkObjectBase.vtkClass = vtk.vtkObjectBase
    registry = get_module_registry()
    registry.add_module(vtkObjectBase)
    if tuple(vtk.vtkVersion().GetVTKVersion().split('.')) < ('5', '7', '0'):
        for child in base.children:
            if child.name in disallowed_classes:
                continue
            createModule(vtkObjectBase, child)
    else:
        for base in g.tree[0]:
            for child in base.children:
                if child.name in disallowed_classes:
                    continue
                createModule(vtkObjectBase, child)
コード例 #4
0
    def createPackage(self):
        pm = get_package_manager()
        if pm.has_package(self.signature):
            package = pm.get_package_by_identifier()
            pm.remove_package(package.codepath)

        reg = core.modules.module_registry.get_module_registry()

        # create a document hash integer from the cached sax tree
        # "name" is what suds use as the cache key
        name = '%s-%s' % (abs(hash(self.address)), "wsdl")
        wsdl = package_cache.get(name)
        if not wsdl:
            debug.critical("File not found in SUDS cache: '%s'" % name)
            self.wsdlHash = '0'
            return
        self.wsdlHash = str(int(hashlib.md5(str(wsdl.root)).hexdigest(), 16))

        package_id = reg.idScope.getNewId(Package.vtType)
        package = Package(id=package_id,
                          codepath=__file__,
                          load_configuration=False,
                          name="SUDS#" + self.address,
                          identifier=self.signature,
                          version=self.wsdlHash,
                          )
        self.package = package
        reg.add_package(package)
        self.module = new_module(Module, str(self.signature))
        reg.add_module(self.module, **{'package':self.signature,
                                       'package_version':self.wsdlHash,
                                       'abstract':True})
コード例 #5
0
ファイル: init.py プロジェクト: painter1/vistrails
    def createPackage(self):
        reg = core.modules.module_registry.get_module_registry()
        if self.signature in reg.packages:
            reg.remove_package(reg.packages[self.signature])

        # create a document hash integer from the cached sax tree
        # "name" is what suds use as the cache key
        name = '%s-%s' % (abs(hash(self.address)), "wsdl")
        wsdl = package_cache.get(name)
        if not wsdl:
            debug.critical("File not found in SUDS cache: '%s'" % name)
            self.wsdlHash = '0'
            return
        self.wsdlHash = str(int(hashlib.md5(str(wsdl.root)).hexdigest(), 16))

        package_id = reg.idScope.getNewId(Package.vtType)
        package = Package(
            id=package_id,
            load_configuration=False,
            name="SUDS#" + self.address,
            identifier=self.signature,
            version=self.wsdlHash,
        )
        self.package = package
        reg.add_package(package)
        reg.signals.emit_new_package(self.signature)

        self.module = new_module(Module, str(self.signature))
        reg.add_module(
            self.module, **{
                'package': self.signature,
                'package_version': self.wsdlHash,
                'abstract': True
            })
コード例 #6
0
    def createFailedPackage(self):
        """ Failed package is created so that the user can remove
        it manually using package submenu """
        pm = get_package_manager()
        if pm.has_package(self.signature):
            # do nothing
            return
        reg = core.modules.module_registry.get_module_registry()

        # create a document hash integer from the cached sax tree
        # "name" is what suds use as the cache key
        name = '%s-%s' % (abs(hash(self.address)), "wsdl")
        self.wsdlHash = '0'

        package_id = reg.idScope.getNewId(Package.vtType)
        package = Package(id=package_id,
                          codepath=__file__,
                          load_configuration=False,
                          name="SUDS#" + self.address,
                          identifier=self.signature,
                          version=self.wsdlHash,
                          )
        suds_package = reg.get_package_by_name(identifier)
        package._module = suds_package.module
        package._init_module = suds_package.init_module
        self.package = package
        reg.add_package(package)
        self.module = new_module(Module, str(self.signature))
        reg.add_module(self.module, **{'package':self.signature,
                                       'package_version':self.wsdlHash,
                                       'abstract':True})
        self.service = -1
コード例 #7
0
def new_constant(name,
                 namespace,
                 identifier,
                 version,
                 widget_type=StandardConstantWidget):
    """new_constant(name: str, namespace: str,widget_type: QWidget type) -> Module
    
    new_constant dynamically creates a new Module derived from Constant
    with a widget type."""
    reg = core.modules.module_registry.get_module_registry()

    def __init__(self):
        Constant.__init__(self)

    @staticmethod
    def get_widget_class():
        return widget_type

    @staticmethod
    def conversion(self):
        return self

    m = new_module(
        Constant, name, {
            '__init__': __init__,
            'get_widget_class': get_widget_class,
            'translate_to_python': conversion
        })
    m.name = name
    m.isEnumeration = True
    reg.add_module(m,
                   namespace=namespace,
                   package=identifier,
                   package_version=version)
    return m
コード例 #8
0
def new_constant(name, namespace, identifier, 
                 version, widget_type=StandardConstantWidget):
    """new_constant(name: str, namespace: str,widget_type: QWidget type) -> Module
    
    new_constant dynamically creates a new Module derived from Constant
    with a widget type."""
    reg = core.modules.module_registry.get_module_registry()
    
    def __init__(self):
        Constant.__init__(self)

    @staticmethod
    def get_widget_class():
        return widget_type

    @staticmethod
    def conversion(self): return self
    
    m = new_module(Constant, name, {'__init__': __init__,
                                    'get_widget_class': get_widget_class,
                                    'translate_to_python': conversion})
    m.name = name
    m.isEnumeration = True
    reg.add_module(m,namespace=namespace,package=identifier,
                   package_version=version)
    return m
コード例 #9
0
def createModule(baseModule, node):
    """ createModule(baseModule: a Module subclass, node: TreeNode) -> None
    Construct a module inherits baseModule with specification from node
    
    """
    if node.name in disallowed_modules: return
    def obsolete_class_list():
        lst = []
        items = ['vtkInteractorStyleTrackball',
                 'vtkStructuredPointsGeometryFilter',
                 'vtkConstrainedPointHandleRepresentation',
                 'vtkTypePromotion']
        def try_to_add_item(item):
            try:
                lst.append(getattr(titan, item))
            except AttributeError:
                pass
        for item in items:
            try_to_add_item(item)
        return lst

    obsolete_list = obsolete_class_list()

    pack1 = vtk
    for i in titan2:
        if getattr(i, node.name, None) != None:
            pack1 = i
    
    def is_abstract():
        """is_abstract tries to instantiate the class. If it's
        abstract, this will raise."""
        # Consider obsolete classes abstract        
        if node.klass in obsolete_list:
            return True
        try:
            getattr(pack1, node.name)()
        except TypeError: # VTK raises type error on abstract classes
            return True
        return False
    
    module = new_module(baseModule, node.name,
                       class_dict(baseModule, node),
                       docstring=getattr(pack1, node.name).__doc__
                       )

    # This is sitting on the class
    if hasattr(fix_classes, node.klass.__name__ + '_fixed'):
        module.vtkClass = getattr(fix_classes, node.klass.__name__ + '_fixed')
    else:
        module.vtkClass = node.klass
    registry = get_module_registry()
    registry.add_module(module, abstract=is_abstract(), 
                        signatureCallable=vtk_hasher)
    for child in node.children:
        if child.name in disallowed_classes:
            continue
        createModule(module, child)
コード例 #10
0
ファイル: init.py プロジェクト: painter1/vistrails
def add_paraview_module(name,
                        proxy,
                        module_type,
                        ns,
                        hide=False,
                        pvFunction=None):

    mod = new_module(module_type, name)
    mod.pvSpace = ns.lower()
    mod.pvClass = name
    if pvFunction != None:
        mod.pvFunction = pvFunction
    if name == 'ProgrammableFilter':
        add_module(mod,
                   name=name,
                   namespace=ns,
                   configureWidgetType=ProgrammableFilterConfigurationWidget)
    else:
        add_module(mod, name=name, namespace=ns)

    for prop in proxy.ListProperties():
        optional = False
        if hide and prop != "Input":
            optional = True
        p = proxy.GetProperty(prop)
        if isinstance(p, sm.ProxyProperty):
            add_input_port(mod, prop, PVBase.PVModule, optional)
            continue
        if isinstance(p, sm.EnumerationProperty):
            add_input_port(mod, prop, core.modules.basic_modules.String,
                           optional)
            continue
        if isinstance(p, sm.VectorProperty):
            params = []
            typ = None
            if p.IsA("vtkSMDoubleVectorProperty"):
                typ = core.modules.basic_modules.Float
            elif p.IsA("vtkSMIntVectorProperty"):
                typ = core.modules.basic_modules.Integer
            elif p.IsA("vtkSMStringVectorProperty"):
                typ = core.modules.basic_modules.String
            elif p.IsA("vtkSMIdTypeVectorProperty"):
                typ = core.modules.basic_modules.Integer
            nel = len(p)
            if nel > 0:
                for i in range(nel):
                    params.append(typ)
            else:
                params.append(typ)
            add_input_port(mod, prop, params, optional)

    add_output_port(mod, "Output", module_type)
コード例 #11
0
    def upgrade_api(self):
        model = self.table.selectionModel()
        indexes = model.selectedIndexes()
        for index in indexes:
            module = self.modules_to_upgrade[index.row()]
            now = datetime.datetime.now()
            name = "%s %d-%d-%d" % (module.name, now.year, now.month, now.day)
            manager = core.packagemanager.get_package_manager()
            package = manager.get_package("edu.cmu.sv.components", "1.0.0")
            new_module = vistrails_module.new_module(Module, name)
            core.modules.module_registry.set_current_package(package)
            new_descriptor = core.modules.module_registry.get_module_registry().add_module(new_module)
            core.modules.module_registry.get_module_registry().update_module(module, new_descriptor)
#            core.modules.module_registry.get_module_registry().delete_module(module.identifier, module.name)
            self.hide()
            return
コード例 #12
0
def createAllModules(g):
    """ createAllModules(g: ClassTree) -> None
    Traverse the VTK class tree and add all modules into the module registry
    
    """
    assert len(g.tree[0]) == 1
    base = g.tree[0][0]
    assert base.name == 'vtkObjectBase'
    vtkObjectBase = new_module(vtkBaseModule, 'vtkObjectBase')
    vtkObjectBase.vtkClass = vtksnl.vtkObjectBase
    registry = get_module_registry()
    registry.add_module(vtkObjectBase)
    for child in base.children:
        if child.name in disallowed_classes:
            continue
        createModule(vtkObjectBase, child)
コード例 #13
0
ファイル: init.py プロジェクト: SinSiXX/opaltoolkit
def build_modules(module_descs):
    new_classes = {}
    for m_name, m_attrs, m_dict in module_descs:
        m_doc = m_attrs.get("_doc", None)
        m_inputs = m_attrs.get("_inputs", [])
        m_outputs = m_attrs.get("_outputs", [])
        if "_inputs" in m_attrs:
            del m_attrs["_inputs"]
        if "_outputs" in m_attrs:
            del m_attrs["_outputs"]
        if "_doc" in m_attrs:
            del m_attrs["_doc"]
            
        m_class = new_module(Module, m_name, m_dict, m_doc)
        m_class._input_ports = expand_ports(m_inputs)
        m_class._output_ports = expand_ports(m_outputs)
        new_classes[m_name] = (m_class, m_attrs)
    return new_classes.values()
コード例 #14
0
ファイル: init.py プロジェクト: imclab/vistrails
def add_paraview_module(name, proxy, module_type, ns, hide=False, pvFunction=None):

    mod = new_module(module_type, name)
    mod.pvSpace = ns.lower()
    mod.pvClass = name
    if pvFunction != None:
        mod.pvFunction = pvFunction
    if name=='ProgrammableFilter':
        add_module(mod, name = name, namespace=ns, configureWidgetType=ProgrammableFilterConfigurationWidget)
    else:
        add_module(mod, name = name, namespace=ns)

    for prop in proxy.ListProperties():
        optional = False
        if hide and prop != "Input":
            optional = True
        p = proxy.GetProperty(prop)
        if isinstance(p, sm.ProxyProperty):
            add_input_port(mod, prop, PVBase.PVModule, optional)
            continue
        if isinstance(p, sm.EnumerationProperty):
            add_input_port(mod, prop, core.modules.basic_modules.String, optional)
            continue
        if isinstance(p, sm.VectorProperty):
            params = []
            typ = None
            if p.IsA("vtkSMDoubleVectorProperty"):
                typ = core.modules.basic_modules.Float
            elif p.IsA("vtkSMIntVectorProperty"):
                typ = core.modules.basic_modules.Integer
            elif p.IsA("vtkSMStringVectorProperty"):
                typ = core.modules.basic_modules.String
            elif p.IsA("vtkSMIdTypeVectorProperty"):
                typ = core.modules.basic_modules.Integer
            nel = len(p)
            if nel > 0:
                for i in range(nel):
                    params.append(typ)
            else:
                params.append(typ)
            add_input_port(mod, prop, params, optional)

    add_output_port(mod, "Output", module_type)
コード例 #15
0
ファイル: init.py プロジェクト: painter1/vistrails
    def createFailedPackage(self):
        """ Failed package is created so that the user can remove
        it manually using package submenu """
        pm = get_package_manager()
        if pm.has_package(self.signature):
            # do nothing
            return
        reg = core.modules.module_registry.get_module_registry()

        # create a document hash integer from the cached sax tree
        # "name" is what suds use as the cache key
        name = '%s-%s' % (abs(hash(self.address)), "wsdl")
        self.wsdlHash = '0'

        package_id = reg.idScope.getNewId(Package.vtType)
        package = Package(
            id=package_id,
            load_configuration=False,
            name="SUDS#" + self.address,
            identifier=self.signature,
            version=self.wsdlHash,
        )
        suds_package = reg.get_package_by_name(identifier)
        package._module = suds_package.module
        package._init_module = suds_package.init_module
        self.package = package
        reg.add_package(package)
        reg.signals.emit_new_package(self.signature)
        self.module = new_module(Module, str(self.signature))
        reg.add_module(
            self.module, **{
                'package': self.signature,
                'package_version': self.wsdlHash,
                'abstract': True
            })
        self.service = -1
コード例 #16
0
    # necessary for group
    d['_input_ports'] = input_ports
    d['_output_ports'] = output_ports
    d['input_remap'] = input_remap
    d['output_remap'] = output_remap
    d['pipeline'] = pipeline

    # abstraction specific
    d['vt_fname'] = vt_fname
    d['vistrail'] = vistrail
    d['internal_version'] = internal_version
    d['uuid'] = uuid

    # print "input_ports", d['_input_ports']
    # print "output_ports", d['_output_ports']
    return new_module(Abstraction, name, d, docstring)

def get_abstraction_dependencies(vistrail, internal_version=-1L):
    if type(vistrail) == type(""):
        vistrail = read_vistrail(vistrail)
    if internal_version == -1L:
        internal_version = vistrail.get_latest_version()
    # action = vistrail.actionMap[internal_version]
    pipeline = vistrail.getPipeline(internal_version)
    
    packages = {}
    for module in pipeline.module_list:
        if module.package not in packages:
            packages[module.package] = set()
        packages[module.package].add(module.descriptor_info)
    return packages
コード例 #17
0
def initialize():
    def parse_error_if_not_equal(s, expected):
        if s != expected:
            err = "Parse error on version line. Was expecting '%s', got '%s'"
            raise Exception(err % (s, expected))
    
    debug.log("ImageMagick VisTrails package")
#    print "Will test ImageMagick presence..."
#
#    if not configuration.check('path'):
#        cmd = 'convert'
#        if (not core.requirements.executable_file_exists('convert') and
#            not core.bundles.install({'linux-ubuntu': 'imagemagick'})):
#            raise core.requirements.MissingRequirement("ImageMagick suite")
#    else:
#        cmd = os.path.join(configuration.path,'convert')
#    cmdline = list2cmdline([cmd, '-version'])
#    
#    if core.system.systemType not in ['Windows', 'Microsoft']: 
#        process = popen2.Popen4(cmdline)
#
#        result = -1
#        while result == -1:
#            result = process.poll()
#        conv_output = process.fromchild
#    else:
#        conv_output, input = popen2.popen4(cmdline)
#        result = 0
#        
#    version_line = conv_output.readlines()[0][:-1].split(' ')
#    if result != 0:
#        raise Exception("ImageMagick does not seem to be present.")
#    print "Ok, found ImageMagick"
#    parse_error_if_not_equal(version_line[0], 'Version:')
#    parse_error_if_not_equal(version_line[1], 'ImageMagick')
#    print "Detected version %s" % version_line[2]
#    global __version__
#    __version__ = version_line[2]

    reg = core.modules.module_registry.get_module_registry()
    basic = core.modules.basic_modules
    reg.add_module(ImageMagick, abstract=True)
    reg.add_input_port(ImageMagick, "input", (basic.File, 'the input file'))
    reg.add_input_port(ImageMagick, "inputFormat", (basic.String, 'coerce interpretation of file to this format'))
    reg.add_input_port(ImageMagick, "outputFormat", (basic.String, 'Force output to be of this format'))

    reg.add_module(Convert)
    reg.add_input_port(Convert, "geometry", (basic.String, 'ImageMagick geometry'))
    reg.add_input_port(Convert, "width", (basic.String, 'width of the geometry for operation'))
    reg.add_input_port(Convert, "height", (basic.String, 'height of the geometry for operation'))
    reg.add_output_port(Convert, "output", (basic.File, 'the output file'))

    for (name, opt, doc_string) in no_param_options:
        m = new_module(Convert, name, no_param_options_method_dict(opt),
                      docstring=doc_string)
        reg.add_module(m)

    for (name, opt, paramName, paramComment) in float_param_options:
        m = new_module(Convert, name, float_param_options_method_dict(opt, paramName))
        reg.add_module(m)
        reg.add_input_port(m, paramName, (basic.Float, paramComment))

    reg.add_module(GaussianBlur)
    reg.add_input_port(GaussianBlur, "radiusSigma", [(basic.Float, 'radius'), (basic.Float, 'sigma')])

    reg.add_module(Scale)

    reg.add_module(CombineRGBA)
    reg.add_input_port(CombineRGBA, "r", basic.File)
    reg.add_input_port(CombineRGBA, "g", basic.File)
    reg.add_input_port(CombineRGBA, "b", basic.File)
    reg.add_input_port(CombineRGBA, "a", basic.File)
    reg.add_input_port(CombineRGBA, "outputFormat", basic.String)
    reg.add_output_port(CombineRGBA, "output", basic.File)
コード例 #18
0
def initialize():
    def parse_error_if_not_equal(s, expected):
        if s != expected:
            err = "Parse error on version line. Was expecting '%s', got '%s'"
            raise Exception(err % (s, expected))

    debug.log("ImageMagick VisTrails package")
    #    print "Will test ImageMagick presence..."
    #
    #    if not configuration.check('path'):
    #        cmd = 'convert'
    #        if (not core.requirements.executable_file_exists('convert') and
    #            not core.bundles.install({'linux-ubuntu': 'imagemagick'})):
    #            raise core.requirements.MissingRequirement("ImageMagick suite")
    #    else:
    #        cmd = os.path.join(configuration.path,'convert')
    #    cmdline = list2cmdline([cmd, '-version'])
    #
    #    if core.system.systemType not in ['Windows', 'Microsoft']:
    #        process = popen2.Popen4(cmdline)
    #
    #        result = -1
    #        while result == -1:
    #            result = process.poll()
    #        conv_output = process.fromchild
    #    else:
    #        conv_output, input = popen2.popen4(cmdline)
    #        result = 0
    #
    #    version_line = conv_output.readlines()[0][:-1].split(' ')
    #    if result != 0:
    #        raise Exception("ImageMagick does not seem to be present.")
    #    print "Ok, found ImageMagick"
    #    parse_error_if_not_equal(version_line[0], 'Version:')
    #    parse_error_if_not_equal(version_line[1], 'ImageMagick')
    #    print "Detected version %s" % version_line[2]
    #    global __version__
    #    __version__ = version_line[2]

    reg = core.modules.module_registry.get_module_registry()
    basic = core.modules.basic_modules
    reg.add_module(ImageMagick, abstract=True)
    reg.add_input_port(ImageMagick, "input", (basic.File, 'the input file'))
    reg.add_input_port(
        ImageMagick, "inputFormat",
        (basic.String, 'coerce interpretation of file to this format'))
    reg.add_input_port(ImageMagick, "outputFormat",
                       (basic.String, 'Force output to be of this format'))

    reg.add_module(Convert)
    reg.add_input_port(Convert, "geometry",
                       (basic.String, 'ImageMagick geometry'))
    reg.add_input_port(Convert, "width",
                       (basic.String, 'width of the geometry for operation'))
    reg.add_input_port(Convert, "height",
                       (basic.String, 'height of the geometry for operation'))
    reg.add_output_port(Convert, "output", (basic.File, 'the output file'))

    for (name, opt, doc_string) in no_param_options:
        m = new_module(Convert,
                       name,
                       no_param_options_method_dict(opt),
                       docstring=doc_string)
        reg.add_module(m)

    for (name, opt, paramName, paramComment) in float_param_options:
        m = new_module(Convert, name,
                       float_param_options_method_dict(opt, paramName))
        reg.add_module(m)
        reg.add_input_port(m, paramName, (basic.Float, paramComment))

    reg.add_module(GaussianBlur)
    reg.add_input_port(GaussianBlur, "radiusSigma", [(basic.Float, 'radius'),
                                                     (basic.Float, 'sigma')])

    reg.add_module(Scale)

    reg.add_module(CombineRGBA)
    reg.add_input_port(CombineRGBA, "r", basic.File)
    reg.add_input_port(CombineRGBA, "g", basic.File)
    reg.add_input_port(CombineRGBA, "b", basic.File)
    reg.add_input_port(CombineRGBA, "a", basic.File)
    reg.add_input_port(CombineRGBA, "outputFormat", basic.String)
    reg.add_output_port(CombineRGBA, "output", basic.File)
コード例 #19
0
ファイル: basic_modules.py プロジェクト: painter1/vistrails
def new_constant(name, py_conversion, default_value, validation,
                 widget_type=None,
                 str_conversion=None, base_class=Constant,
                 compute=None, query_widget_type=None,
                 query_compute=None,
                 param_explore_widget_list=None):
    """new_constant(name: str, 
                    py_conversion: callable,
                    default_value: python_type,
                    validation: callable,
                    widget_type: (path, name) tuple or QWidget type,
                    str_conversion: callable,
                    base_class: class,
                    compute: callable,
                    query_widget_type: (path, name) tuple or QWidget type,
                    query_compute: static callable,
                    param_explore_widget_list: 
                        list((path, name) tuple or QWidget type)) -> Module

    new_constant dynamically creates a new Module derived from
    Constant with given py_conversion and str_conversion functions, a
    corresponding python type and a widget type. py_conversion is a
    python callable that takes a string and returns a python value of
    the type that the class should hold. str_conversion does the reverse.

    This is the quickest way to create new Constant Modules."""
    
    def create_init(base_class):
        def __init__(self):
            base_class.__init__(self)
        return __init__

    d = {'__init__': create_init(base_class),
         'validate': validation,
         'translate_to_python': py_conversion,
         'default_value': default_value,
         }
    if str_conversion is not None:
        d['translate_to_string'] = str_conversion
    if compute is not None:
        d['compute'] = compute
    if query_compute is not None:
        d['query_compute'] = query_compute
    if widget_type is not None:
        @staticmethod
        def get_widget_class():
            return widget_type
        d['get_widget_class'] = get_widget_class
    if query_widget_type is not None:
        @staticmethod
        def get_query_widget_class():
            return query_widget_type
        d['get_query_widget_class'] = get_query_widget_class
    if param_explore_widget_list is not None:
        @staticmethod
        def get_param_explore_widget_list():
            return param_explore_widget_list
        d['get_param_explore_widget_list'] = get_param_explore_widget_list

    m = new_module(base_class, name, d)
    m._input_ports = [('value', m)]
    m._output_ports = [('value', m)]
    return m
コード例 #20
0
def add_tool(path):
    global cl_tools
    # first create classes
    tool_name = os.path.basename(path)
    if not tool_name.endswith(SUFFIX):
        return
    (tool_name, _) = os.path.splitext(tool_name)

    if tool_name in cl_tools:
        debug.critical("Package CLTools already added: '%s'" % tool_name)
    try:
        conf = json.load(open(path))
    except ValueError as exc:
        debug.critical("Package CLTools could not parse '%s'" % path, str(exc))
        return

    def compute(self):
        """ 1. read inputs
            2. call with inputs
            3. set outputs
        """
        # add all arguments as an unordered list
        args = [self.conf["command"]]
        file_std = "options" in self.conf and "std_using_files" in self.conf["options"]
        setOutput = []  # (name, File) - set File contents as output for name
        open_files = []
        stdin = None
        kwargs = {}
        for type, name, klass, options in self.conf["args"]:
            type = type.lower()
            klass = klass.lower()
            if "constant" == type:
                args.append(name)
            elif "input" == type:
                # handle multiple inputs
                values = self.forceGetInputListFromPort(name)
                if values and "list" == klass:
                    values = values[0]
                    klass = options["type"].lower() if "type" in options else "string"
                for value in values:
                    if "flag" == klass:
                        if value and "flag" in options:
                            value = options["flag"]
                        else:
                            continue
                    elif "file" == klass:
                        value = str(value.name)
                    # check for flag and append file name
                    if not "flag" == klass and "flag" in options:
                        args.append(options["flag"])
                    if "prefix" in options:
                        value = options["prefix"] + str(value)
                    args.append(value)
            elif "output" == type:
                # output must be a filename but we may convert the result to a string
                # create new file
                file = _file_pool.create_file(suffix=TEMPSUFFIX)
                fname = file.name
                if "prefix" in options:
                    fname = options["prefix"] + fname
                if "flag" in options:
                    args.append(options["flag"])
                args.append(fname)
                if "file" == klass:
                    self.setResult(name, file)
                else:  # assume String - set to string value after execution
                    setOutput.append((name, file))
        if "stdin" in self.conf:
            name, type, options = self.conf["stdin"]
            type = type.lower()
            if self.hasInputFromPort(name):
                value = self.getInputFromPort(name)
                if "file" == type:
                    if file_std:
                        f = open(value.name, "rb")
                        data = f.read()
                        stdin = ""
                        while data:
                            stdin += data
                            data = f.read()
                        f.close()
                    else:
                        f = open(value.name, "rb")
                else:  # assume String
                    if file_std:
                        file = _file_pool.create_file(suffix=TEMPSUFFIX)
                        f = open(file.name, "w")
                        f.write(str(value))
                        f.close()
                        f = open(file.name)
                    else:
                        stdin = value
                if file_std:
                    open_files.append(f)
                    kwargs["stdin"] = f.fileno()
                else:
                    kwargs["stdin"] = subprocess.PIPE
        if "stdout" in self.conf:
            if file_std:
                name, type, options = self.conf["stdout"]
                type = type.lower()
                file = _file_pool.create_file(suffix=TEMPSUFFIX)
                if "file" == type:
                    self.setResult(name, file)
                else:  # assume String - set to string value after execution
                    setOutput.append((name, file))
                f = open(file.name, "wb")
                open_files.append(f)
                kwargs["stdout"] = f.fileno()
            else:
                kwargs["stdout"] = subprocess.PIPE
        if "stderr" in self.conf:
            if file_std:
                name, type, options = self.conf["stderr"]
                type = type.lower()
                file = _file_pool.create_file(suffix=TEMPSUFFIX)
                if "file" == type:
                    self.setResult(name, file)
                else:  # assume String - set to string value after execution
                    setOutput.append((name, file))
                f = open(file.name, "wb")
                open_files.append(f)
                kwargs["stderr"] = f.fileno()
            else:
                kwargs["stderr"] = subprocess.PIPE
        # On windows, builtin commands like cd/dir must use shell=True
        if core.system.systemType in ["Windows", "Microsoft"] and args[0] in ["dir", "cd"]:
            kwargs["shell"] = True

        if configuration.check("env"):
            env = os.environ
            for var in configuration.env.split(";"):
                key, value = var.split("=")
                key = key.strip()
                value = value.strip()
                if key:
                    env[key] = value
            kwargs["env"] = env
        # print "calling", args, kwargs
        process = subprocess.Popen(args, **kwargs)
        if file_std:
            process.wait()
        else:
            # if stdin:
            #    print "stdin:", len(stdin), stdin[:30]
            stdout, stderr = _eintr_retry_call(process.communicate, stdin)
            # stdout, stderr = process.communicate(stdin)
            # if stdout:
            #    print "stdout:", len(stdout), stdout[:30]
            # if stderr:
            #    print "stderr:", len(stderr), stderr[:30]

        for f in open_files:
            f.close()

        for name, file in setOutput:
            f = open(file.name)
            self.setResult(name, f.read())
            f.close()

        if not file_std:
            if stdout and "stdout" in self.conf:
                name, type, options = self.conf["stdout"]
                type = type.lower()
                if "file" == type:
                    file = _file_pool.create_file(suffix=TEMPSUFFIX)
                    f = open(file.name, "w")
                    f.write(stdout)
                    f.close()
                    self.setResult(name, file)
                else:  # assume String - set to string value after execution
                    self.setResult(name, stdout)
            if stderr and "stderr" in self.conf:
                name, type, options = self.conf["stderr"]
                type = type.lower()
                if "file" == type:
                    file = _file_pool.create_file(suffix=TEMPSUFFIX)
                    f = open(file.name, "w")
                    f.write(stderr)
                    f.close()
                    self.setResult(name, file)
                else:  # assume String - set to string value after execution
                    self.setResult(name, stderr)

    # create docstring
    d = """This module is a wrapper for the command line tool '%s'""" % conf["command"]
    # create module
    M = new_module(CLTools, tool_name, {"compute": compute, "conf": conf, "tool_name": tool_name, "__doc__": d})
    reg = core.modules.module_registry.get_module_registry()
    reg.add_module(M, package=identifier, package_version=version)

    def to_vt_type(s):
        # add recognized types here - default is String
        return "(edu.utah.sci.vistrails.basic:%s)" % {"file": "File", "flag": "Boolean", "list": "List"}.get(
            str(s).lower(), "String"
        )

    # add module ports
    if "stdin" in conf:
        name, type, options = conf["stdin"]
        optional = "required" not in options
        reg.add_input_port(M, name, to_vt_type(type), optional=optional)
    if "stdout" in conf:
        name, type, options = conf["stdout"]
        optional = "required" not in options
        reg.add_output_port(M, name, to_vt_type(type), optional=optional)
    if "stderr" in conf:
        name, type, options = conf["stderr"]
        optional = "required" not in options
        reg.add_output_port(M, name, to_vt_type(type), optional=optional)
    for type, name, klass, options in conf["args"]:
        optional = "required" not in options
        if "input" == type.lower():
            reg.add_input_port(M, name, to_vt_type(klass), optional=optional)
        elif "output" == type.lower():
            reg.add_output_port(M, name, to_vt_type(klass), optional=optional)
    cl_tools[tool_name] = M
コード例 #21
0
    def createMethodClasses(self):
        # register modules
        reg = core.modules.module_registry.get_module_registry()
        self.methodClasses = {}
        for m in self.wsmethods.itervalues():
            def compute(self):
                # create dict of inputs
                params = {}
                mname = self.wsmethod.qname[0]
                for name in self.wsmethod.inputs:
                    name = str(name)
                    if self.hasInputFromPort(name):
                        params[name] = self.getInputFromPort(name)
                        if params[name].__class__.__name__ == 'UberClass':
                            params[name] = params[name].value
                        params[name] = self.service.makeDictType(params[name])
                try:
#                    print "params:", str(params)[:400]
#                    self.service.service.set_options(retxml = True)
#                    result = getattr(self.service.service.service, mname)(**params)
#                    print "result:", str(result)[:400]
#                    self.service.service.set_options(retxml = False)
                    result = getattr(self.service.service.service, mname)(**params)
                except Exception, e:
                    raise ModuleError(self, "Error invoking method %s: %s"%(name, str(e)))
                for name, qtype in self.wsmethod.outputs.iteritems():
                    if isinstance(result, list):
                        # if result is a list just set the output
                        self.setResult(name, result)
                    elif qtype[0] == 'Array':
                        # if result is a type but type is a list try to extract the correct element
                        if len(result.__keylist__):
                            self.setResult(name, getattr(result, result.__keylist__[0]))
                        else:
                            self.setResult(name, result)
                    elif result.__class__.__name__ == 'Text':
                        # only text returned so we assume each output wants all of it
                        self.setResult(name, str(result.trim()))
                    elif result.__class__.__name__ == qtype[0]:
                        # the return value is this type
                        self.setResult(name, result)
                    elif hasattr(result, name):
                        self.setResult(name, getattr(result, name))
                    else:
                        # nothing matches - assume it is an attribute of the correct class
                        class UberClass:
                            def __init__(self, value):
                                self.value = value
                        self.setResult(name, UberClass(result))

            # create docstring
            inputs = ", ".join([t[0]+' '+i for i,t in m.inputs.iteritems()])
            outputs = ", ".join([t[0]+' '+o for o,t in m.outputs.iteritems()])
            d = """This module was created using a wrapper for SUDS (fedorahosted.org/suds/)
from the WSDL spec at:
   %s
It is a WSDL method with signature:
   %s(%s)
Outputs:
   (%s)
"""%(self.address, m.qname[0], inputs, outputs)

            M = new_module(self.module, str(m.qname[0]), {"compute":compute,
                                                          "wsmethod":m,
                                                          "service":self,
                                                           "__doc__":d})
            self.methodClasses[m.qname] = M
            reg.add_module(M, **{'namespace':'Methods',
                                 'package':self.signature,
                                 'package_version':self.wsdlHash})
            # add ports
            for p, ptype in m.inputs.iteritems():
                if ptype[1] in wsdlSchemas:
                    c = wsdlTypesDict[ptype[0]]
                elif ptype in self.typeClasses:
                    c = self.typeClasses[ptype]
                else:
                    # use string as default
                    c = wsdlTypesDict['string']
                reg.add_input_port(M, p, c)
            for p, ptype in m.outputs.iteritems():
                if ptype[1] in wsdlSchemas:
                    c = wsdlTypesDict[ptype[0]]
                elif ptype in self.typeClasses:
                    c = self.typeClasses[ptype]
                else:
                    # use string as default
                    c = wsdlTypesDict['string']
                reg.add_output_port(M, p, c)
コード例 #22
0
    def createTypeClasses(self):
        # first create classes
        reg = core.modules.module_registry.get_module_registry()
        self.typeClasses = {}
        for t in self.wstypes.itervalues():
            def compute(self):
                """ 1. use type input as object or create new
                    2. add other inputs to obj
                    3. set obj and parts as outputs
                """
                if self.wstype.enum:
                    # only makes sure the enum is one of the valid values
                    p = self.wstype.parts['value']
                    if self.hasInputFromPort(p.name):
                        obj = self.getInputFromPort(p.name)
                    else:
                        obj = p.enum[0] if len(p.enum) else ''
                    if self.hasInputFromPort('value'):
                        obj = self.getInputFromPort('value')
                    if obj not in p.enum:
                        raise ModuleError(self,
                                 "'%s' is not one of the valid enums: %s" %
                                 (obj, str(p.enum)) )
                    self.setResult(self.wstype.qname[0], obj)
                    self.setResult('value', obj)
                    return
                if self.hasInputFromPort(self.wstype.qname[0]):
                    obj = self.getInputFromPort(self.wstype.qname[0])
                else:
                    obj = {}
                    s = "{%s}%s"%(self.wstype.qname[1],self.wstype.qname[0])
                    try:
                        obj = self.service.service.factory.create(s)
                    except (suds.TypeNotFound, suds.BuildError):
                        raise ModuleError("Type not found: %s" % s)
                for part in self.wstype.parts.itervalues():
                    # 
                    if obj.__class__.__name__ == 'UberClass':
                        # UberClass is a placeholder and its value is assumed
                        # to be the correct attribute value
                        if len(self.wstype.parts) == 1:
                            setattr(obj, part.name, obj.value)
                        else:
                            # update each attribute
                            if hasattr(obj.value, part.name):
                                setattr(obj, part.name, getattr(obj.value, part.name))
                    if self.hasInputFromPort(part.name):
                        p = self.getInputFromPort(part.name)
                        if hasattr(obj, part.name):
                            setattr(obj, part.name, p)
                        else:
                            # do it anyway - assume attribute missing in template
                            setattr(obj, part.name, p)
                    if hasattr(obj, part.name):
                        # 
                        res = getattr(obj, part.name)
                        self.setResult(part.name, res)
                self.setResult(self.wstype.qname[0], obj)

            # create docstring
            parts = ", ".join([i.type[0]+' '+i.name for i in t.parts.itervalues()])
            d = """This module was created using a wrapper for SUDS (fedorahosted.org/suds/)
from the WSDL spec at:
   %s
It is a WSDL type with signature:
   %s(%s)"""%(self.address, t.qname[0], parts)
            M = new_module(self.module, str(t.qname[0]),{"compute":compute,
                                                         "wstype":t,
                                                         "service":self,
                                                         "__doc__":d})
            self.typeClasses[t.qname] = M
            reg.add_module(M, **{'namespace':'Types',
                                 'package':self.signature,
                                 'package_version':self.wsdlHash})

        # then add ports
        for t in self.wstypes:
            wstype = self.wstypes[t]
            # get type module
            if t[1] in wsdlSchemas:
                c = wsdlTypesDict[t[0]]
            elif t in self.typeClasses:
                c = self.typeClasses[t]
            else:
                debug.critical("Cannot find module for type: " + str(t))
                continue
            # add self ports
            reg.add_input_port(self.typeClasses[t], t[0], c)
            reg.add_output_port(self.typeClasses[t], t[0], c)
            for p in wstype.parts:
                part = wstype.parts[p]
                # get type module
                ptype = part.type
                if part.max is not None and (part.max == 'unbounded' or int(part.max)>1):
                    # it can be multiple objects which means we need to make it a list
                    c = core.modules.basic_modules.List
                elif ptype[1] in wsdlSchemas:
                    c = wsdlTypesDict[ptype[0]]
                elif ptype in self.typeClasses:
                    c = self.typeClasses[ptype]
                else:
                    debug.critical("Cannot find module for type: " + str(ptype))
                    continue
                # add as both input and output port
                reg.add_input_port(self.typeClasses[t], p, c,
                                   optional=part.optional)
                reg.add_output_port(self.typeClasses[t], p, c,
                                    optional=part.optional)
コード例 #23
0
                    file = self.interpreter.filePool.create_file(
                        suffix=DEFAULTFILESUFFIX)
                    f = open(file.name, 'w')
                    f.write(stderr)
                    f.close()
                    self.setResult(name, file)
                else:  # assume String - set to string value after execution
                    self.setResult(name, stderr)

    # create docstring
    d = """This module is a wrapper for the command line tool '%s'""" % \
        conf['command']
    # create module
    M = new_module(CLTools, tool_name, {
        "compute": compute,
        "conf": conf,
        "tool_name": tool_name,
        "__doc__": d
    })
    reg = core.modules.module_registry.get_module_registry()
    reg.add_module(M, package=identifier, package_version=version)

    def to_vt_type(s):
        # add recognized types here - default is String
        return '(edu.utah.sci.vistrails.basic:%s)' % \
          {'file':'File', 'flag':'Boolean', 'list':'List',
           'float':'Float','integer':'Integer'
          }.get(str(s).lower(), 'String')

    # add module ports
    if 'stdin' in conf:
        name, type, options = conf['stdin']
コード例 #24
0
ファイル: init.py プロジェクト: painter1/vistrails
    def createTypeClasses(self):
        # first create classes
        reg = core.modules.module_registry.get_module_registry()
        self.typeClasses = {}
        for t in self.wstypes.itervalues():

            def compute(self):
                """ 1. use type input as object or create new
                    2. add other inputs to obj
                    3. set obj and parts as outputs
                """
                if self.wstype.enum:
                    # only makes sure the enum is one of the valid values
                    p = self.wstype.parts['value']
                    if self.hasInputFromPort(p.name):
                        obj = self.getInputFromPort(p.name)
                    else:
                        obj = p.enum[0] if len(p.enum) else ''
                    if self.hasInputFromPort('value'):
                        obj = self.getInputFromPort('value')
                    if obj not in p.enum:
                        raise ModuleError(
                            self, "'%s' is not one of the valid enums: %s" %
                            (obj, str(p.enum)))
                    self.setResult(self.wstype.qname[0], obj)
                    self.setResult('value', obj)
                    return
                if self.hasInputFromPort(self.wstype.qname[0]):
                    obj = self.getInputFromPort(self.wstype.qname[0])
                else:
                    obj = {}
                    s = "{%s}%s" % (self.wstype.qname[1], self.wstype.qname[0])
                    try:
                        obj = self.service.service.factory.create(s)
                    except (suds.TypeNotFound, suds.BuildError):
                        raise ModuleError("Type not found: %s" % s)
                for part in self.wstype.parts.itervalues():
                    #
                    if obj.__class__.__name__ == 'UberClass':
                        # UberClass is a placeholder and its value is assumed
                        # to be the correct attribute value
                        if len(self.wstype.parts) == 1:
                            setattr(obj, part.name, obj.value)
                        else:
                            # update each attribute
                            if hasattr(obj.value, part.name):
                                setattr(obj, part.name,
                                        getattr(obj.value, part.name))
                    if self.hasInputFromPort(part.name):
                        p = self.getInputFromPort(part.name)
                        if hasattr(obj, part.name):
                            setattr(obj, part.name, p)
                        else:
                            # do it anyway - assume attribute missing in template
                            setattr(obj, part.name, p)
                    if hasattr(obj, part.name):
                        #
                        res = getattr(obj, part.name)
                        self.setResult(part.name, res)
                self.setResult(self.wstype.qname[0], obj)

            # create docstring
            parts = ", ".join(
                [i.type[0] + ' ' + i.name for i in t.parts.itervalues()])
            d = """This module was created using a wrapper for SUDS (fedorahosted.org/suds/)
from the WSDL spec at:
   %s
It is a WSDL type with signature:
   %s(%s)""" % (self.address, t.qname[0], parts)
            M = new_module(self.module, str(t.qname[0]), {
                "compute": compute,
                "wstype": t,
                "service": self,
                "__doc__": d
            })
            self.typeClasses[t.qname] = M
            reg.add_module(
                M, **{
                    'namespace': 'Types',
                    'package': self.signature,
                    'package_version': self.wsdlHash
                })

        # then add ports
        for t in self.wstypes:
            wstype = self.wstypes[t]
            # get type module
            if t[1] in wsdlSchemas:
                c = wsdlTypesDict[t[0]]
            elif t in self.typeClasses:
                c = self.typeClasses[t]
            else:
                debug.critical("Cannot find module for type: " + str(t))
                continue
            # add self ports
            reg.add_input_port(self.typeClasses[t], t[0], c)
            reg.add_output_port(self.typeClasses[t], t[0], c)
            for p in wstype.parts:
                part = wstype.parts[p]
                # get type module
                ptype = part.type
                if part.max is not None and (part.max == 'unbounded'
                                             or int(part.max) > 1):
                    # it can be multiple objects which means we need to make it a list
                    c = core.modules.basic_modules.List
                elif ptype[1] in wsdlSchemas:
                    c = wsdlTypesDict[ptype[0]]
                elif ptype in self.typeClasses:
                    c = self.typeClasses[ptype]
                else:
                    debug.critical("Cannot find module for type: " +
                                   str(ptype))
                    continue
                # add as both input and output port
                reg.add_input_port(self.typeClasses[t],
                                   p,
                                   c,
                                   optional=part.optional)
                reg.add_output_port(self.typeClasses[t],
                                    p,
                                    c,
                                    optional=part.optional)
コード例 #25
0
ファイル: sub_module.py プロジェクト: painter1/vistrails
    # necessary for group
    d['_input_ports'] = input_ports
    d['_output_ports'] = output_ports
    d['input_remap'] = input_remap
    d['output_remap'] = output_remap
    d['pipeline'] = pipeline

    # abstraction specific
    d['vt_fname'] = vt_fname
    d['vistrail'] = vistrail
    d['internal_version'] = internal_version
    d['uuid'] = uuid

    # print "input_ports", d['_input_ports']
    # print "output_ports", d['_output_ports']
    return new_module(Abstraction, name, d, docstring)

def get_abstraction_dependencies(vistrail, internal_version=-1L):
    if type(vistrail) == type(""):
        vistrail = read_vistrail(vistrail)
    if internal_version == -1L:
        internal_version = vistrail.get_latest_version()
    # action = vistrail.actionMap[internal_version]
    pipeline = vistrail.getPipeline(internal_version)
    
    packages = {}
    for module in pipeline.module_list:
        if module.package not in packages:
            packages[module.package] = set()
        packages[module.package].add(module.descriptor_info)
    return packages
コード例 #26
0
ファイル: init.py プロジェクト: sdeclere/bioport
                    f.close()
                    self.setResult(name, file)
                else: # assume String - set to string value after execution
                    self.setResult(name, stderr)

    # <stef> : add categories 
    cats =  [str(x) for x in conf['groups']]
    np =  " | ".join(cats)

    # create docstring
    d = """This module is a wrapper for the command line tool '%s'""" % \
        conf['command']

    # create module
    M = new_module(CLTools, tool_name,{"compute": compute,
                                           "conf": conf,
                                           "tool_name": tool_name,
                                           "__doc__": d})
    reg = core.modules.module_registry.get_module_registry()
    reg.add_module(M, 
                   package=identifier, 
                   package_version=version, 
                   namespace=np)

    def to_vt_type(s):
        # add recognized types here - default is String
        return '(edu.utah.sci.vistrails.basic:%s)' % \
          {'file':'File', 'flag':'Boolean', 'list':'List',
           'float':'Float','integer':'Integer'
          }.get(str(s).lower(), 'String')

    # add module ports
コード例 #27
0
ファイル: init.py プロジェクト: painter1/vistrails
    def createMethodClasses(self):
        # register modules
        reg = core.modules.module_registry.get_module_registry()
        self.methodClasses = {}
        for m in self.wsmethods.itervalues():

            def compute(self):
                # create dict of inputs
                params = {}
                mname = self.wsmethod.qname[0]
                for name in self.wsmethod.inputs:
                    name = str(name)
                    if self.hasInputFromPort(name):
                        params[name] = self.getInputFromPort(name)
                        if params[name].__class__.__name__ == 'UberClass':
                            params[name] = params[name].value
                        params[name] = self.service.makeDictType(params[name])
                try:
                    #                    print "params:", str(params)[:400]
                    #                    self.service.service.set_options(retxml = True)
                    #                    result = getattr(self.service.service.service, mname)(**params)
                    #                    print "result:", str(result)[:400]
                    #                    self.service.service.set_options(retxml = False)
                    result = getattr(self.service.service.service,
                                     mname)(**params)
                except Exception, e:
                    raise ModuleError(
                        self, "Error invoking method %s: %s" % (name, str(e)))
                for name, qtype in self.wsmethod.outputs.iteritems():
                    if isinstance(result, list):
                        # if result is a list just set the output
                        self.setResult(name, result)
                    elif qtype[0] == 'Array':
                        # if result is a type but type is a list try to extract the correct element
                        if len(result.__keylist__):
                            self.setResult(
                                name, getattr(result, result.__keylist__[0]))
                        else:
                            self.setResult(name, result)
                    elif result.__class__.__name__ == 'Text':
                        # only text returned so we assume each output wants all of it
                        self.setResult(name, str(result.trim()))
                    elif result.__class__.__name__ == qtype[0]:
                        # the return value is this type
                        self.setResult(name, result)
                    elif hasattr(result, name):
                        self.setResult(name, getattr(result, name))
                    else:
                        # nothing matches - assume it is an attribute of the correct class
                        class UberClass:
                            def __init__(self, value):
                                self.value = value

                        self.setResult(name, UberClass(result))

            # create docstring
            inputs = ", ".join(
                [t[0] + ' ' + i for i, t in m.inputs.iteritems()])
            outputs = ", ".join(
                [t[0] + ' ' + o for o, t in m.outputs.iteritems()])
            d = """This module was created using a wrapper for SUDS (fedorahosted.org/suds/)
from the WSDL spec at:
   %s
It is a WSDL method with signature:
   %s(%s)
Outputs:
   (%s)
""" % (self.address, m.qname[0], inputs, outputs)

            M = new_module(self.module, str(m.qname[0]), {
                "compute": compute,
                "wsmethod": m,
                "service": self,
                "__doc__": d
            })
            self.methodClasses[m.qname] = M
            reg.add_module(
                M, **{
                    'namespace': 'Methods',
                    'package': self.signature,
                    'package_version': self.wsdlHash
                })
            # add ports
            for p, ptype in m.inputs.iteritems():
                if ptype[1] in wsdlSchemas:
                    c = wsdlTypesDict[ptype[0]]
                elif ptype in self.typeClasses:
                    c = self.typeClasses[ptype]
                else:
                    # use string as default
                    c = wsdlTypesDict['string']
                reg.add_input_port(M, p, c)
            for p, ptype in m.outputs.iteritems():
                if ptype[1] in wsdlSchemas:
                    c = wsdlTypesDict[ptype[0]]
                elif ptype in self.typeClasses:
                    c = self.typeClasses[ptype]
                else:
                    # use string as default
                    c = wsdlTypesDict['string']
                reg.add_output_port(M, p, c)