def __init__(self, *args, **kwargs):
        """The preferred way to create a port is to pass a PortSpec with
        new information.  The construcotr pulls name, type, and signature 
        info from the PortSpec.
        
        Example: Port(id=<id>, spec=<port_spec>, moduleId=<id>, 
                      moduleName=<name>)

        You can also pass the name, type, and signature, separately.
        
        Example: Port(id=<id>, name=<name>, type=[source|destination],
                      signature=<sig>, moduleId=<id>, moduleName=<name>)

        """

        self._spec = None
        self._descriptors = None
        if 'spec' in kwargs:
            self._spec = kwargs['spec']
            del kwargs['spec']
            if 'name' not in kwargs:
                kwargs['name'] = self._spec.name
            if 'type' not in kwargs:
                if self._spec.type in PortSpec.port_type_map:
                    kwargs['type'] = PortSpec.port_type_map[self._spec.type]
            if 'signature' not in kwargs:
                kwargs['signature'] = self._spec.sigstring
#         else:
#             self.spec = None
        if 'id' not in kwargs:
            kwargs['id'] = -1
        if 'moduleId' not in kwargs:
            kwargs['moduleId'] = 0
        if 'moduleName' not in kwargs:
            kwargs['moduleName'] = ""
        if 'name' not in kwargs:
            kwargs['name'] = ""
        if 'signature' not in kwargs:
            kwargs['signature'] = ""

        DBPort.__init__(self, *args, **kwargs)

        self.set_defaults()

#             # if there is no spec, create it
#             spec_type = PortSpec.port_type_map.inverse[self.type]
#             self._spec = PortSpec(name=self.name, 
#                                   type=spec_type,
#                                   sigstring=self.signature)
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/core/vistrail/port.py/Port.__init__/original