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