def __init__(self, *args, **kwargs):
        if "sigstring" in kwargs:
            sigstring = kwargs["sigstring"]
            del kwargs["sigstring"]

            (package, module, namespace) = \
                parse_port_spec_item_string(sigstring)
            if "package" not in kwargs:
                kwargs["package"] = package
            if "module" not in kwargs:
                kwargs["module"] = module
            if "namespace" not in kwargs:
                kwargs["namespace"] = namespace
        if "values" in kwargs:
            if (kwargs["values"] is not None and
                    not isinstance(kwargs["values"], basestring)):
                kwargs["values"] = str(kwargs["values"])
        if 'id' not in kwargs:
            kwargs['id'] = -1

        def update_identifier(identifier):
            """check for changed identifiers (e.g. edu.utah.sci.vistrails ->
            org.vistrails.vistrails) and use the current one.

            """
            from vistrails.core.modules.module_registry import \
                get_module_registry, MissingPackage
            reg = get_module_registry()
            try:
                identifier = reg.get_package_by_name(identifier).identifier
            except MissingPackage:
                # catch this later, just trying to ensure that old
                # identifiers are updated
                pass
            return identifier
            
        # args[3] is the package argument
        # FIXME this is schema-dependent...
        if len(args) > 3:
            args[3] = update_identifier(args[3])
        if "package" in kwargs:
            kwargs["package"] = update_identifier(kwargs["package"])
        DBPortSpecItem.__init__(self, *args, **kwargs)
        self.set_defaults()
Пример #2
0
    def __init__(self, *args, **kwargs):
        if "sigstring" in kwargs:
            sigstring = kwargs["sigstring"]
            del kwargs["sigstring"]

            (package, module, namespace) = \
                parse_port_spec_item_string(sigstring)
            if "package" not in kwargs:
                kwargs["package"] = package
            if "module" not in kwargs:
                kwargs["module"] = module
            if "namespace" not in kwargs:
                kwargs["namespace"] = namespace
        if "values" in kwargs:
            if (kwargs["values"] is not None
                    and not isinstance(kwargs["values"], basestring)):
                kwargs["values"] = str(kwargs["values"])
        if 'id' not in kwargs:
            kwargs['id'] = -1

        def update_identifier(identifier):
            """check for changed identifiers (e.g. edu.utah.sci.vistrails ->
            org.vistrails.vistrails) and use the current one.

            """
            reg = get_module_registry()
            MissingPackage = get_MissingPackage()
            try:
                identifier = reg.get_package_by_name(identifier).identifier
            except MissingPackage:
                # catch this later, just trying to ensure that old
                # identifiers are updated
                pass
            return identifier

        # args[3] is the package argument
        # FIXME this is schema-dependent...
        if len(args) > 3:
            args[3] = update_identifier(args[3])
        if "package" in kwargs:
            kwargs["package"] = update_identifier(kwargs["package"])
        DBPortSpecItem.__init__(self, *args, **kwargs)
        self.set_defaults()
Пример #3
0
    def test_port_spec_copy(self):
        id_scope = IdScope()
        psi = DBPortSpecItem(id=id_scope.getNewId(DBPortSpecItem.vtType),
                             pos=0,
                             module="File",
                             package="org.vistrails.vistrails.basic")

        ps1 = DBPortSpec(id=id_scope.getNewId(DBPortSpec.vtType),
                         portSpecItems=[psi,])
        ops = create_copy_op_chain(ps1, id_scope=id_scope)
        self.assertNotEqual(ps1.db_portSpecItems[0].db_id,
                            ops[0].db_data.db_portSpecItems[0].db_id)
Пример #4
0
 def do_copy(self, new_ids=False, id_scope=None, id_remap=None):
     cp = DBPortSpecItem.do_copy(self, new_ids, id_scope, id_remap)
     cp.__class__ = PortSpecItem
     cp.set_defaults(self)
     return cp
 def do_copy(self, new_ids=False, id_scope=None, id_remap=None):
     cp = DBPortSpecItem.do_copy(self, new_ids, id_scope, id_remap)
     cp.__class__ = PortSpecItem
     cp.set_defaults(self)
     return cp