3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 01:09:22 +01:00

NetworkCoreWithUtils: shortcut _get_SID/UID if the target already exists

This commit is contained in:
James Lu 2017-07-02 22:35:39 -07:00
parent e866e9eb7b
commit bbc4dec8dd

View File

@ -1100,6 +1100,10 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
def _get_SID(self, sname): def _get_SID(self, sname):
"""Returns the SID of a server with the given name, if present.""" """Returns the SID of a server with the given name, if present."""
name = sname.lower() name = sname.lower()
if name in self.servers:
return name
for k, v in self.servers.items(): for k, v in self.servers.items():
if v.name.lower() == name: if v.name.lower() == name:
return k return k
@ -1110,6 +1114,10 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
def _get_UID(self, target): def _get_UID(self, target):
"""Converts a nick argument to its matching UID. This differs from irc.nick_to_uid() """Converts a nick argument to its matching UID. This differs from irc.nick_to_uid()
in that it returns the original text instead of None, if no matching nick is found.""" in that it returns the original text instead of None, if no matching nick is found."""
if target in self.users:
return target
target = self.nick_to_uid(target) or target target = self.nick_to_uid(target) or target
return target return target
_getUid = _get_UID _getUid = _get_UID