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()
def do_copy(self, new_ids=False, id_scope=None, id_remap=None): cp = DBPort.do_copy(self, new_ids, id_scope, id_remap) cp.__class__ = Port cp.set_defaults(self) return cp