def __find(self, name):
port = None<EOL>if not len(self.__ports):<EOL><INDENT>raise Exception('<STR_LIT>' % self.__qn)<EOL><DEDENT>if isinstance(name, int):<EOL><INDENT>qn = '<STR_LIT>' % (self.__qn, name)<EOL>try:<EOL><INDENT>port = self.__ports[name]<EOL><DEDENT>except IndexError:<EOL><INDENT>raise PortNotFound(qn)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>qn = '<STR_LIT:.>'.join((self.__qn, name))<EOL>for p in self.__ports:<EOL><INDENT>if name == p.name:<EOL><INDENT>port = p<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if port is None:<EOL><INDENT>raise PortNotFound(qn)<EOL><DEDENT>qn = '<STR_LIT:.>'.join((self.__qn, port.name))<EOL>return MethodSelector(self.__client, port.methods, qn)<EOL>
Find a I{port} by name (string) or index (integer).
@param name: The name (or index) of a port.
@type name: (int|str)
@return: A L{MethodSelector} for the found port.
@rtype: L{MethodSelector}.