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

classes: make _to_lower_core and _expandPUID type-safe

This commit is contained in:
James Lu 2018-02-24 14:18:18 -05:00
parent 2aca4e39c1
commit 50f8cde694

View File

@ -510,6 +510,8 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
@staticmethod
@functools.lru_cache(maxsize=2048)
def _to_lower_core(text, casemapping='rfc1459'):
if not text:
return text
if casemapping == 'rfc1459':
text = text.replace('{', '[')
text = text.replace('}', ']')
@ -1232,8 +1234,9 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
Returns the nick or server name for the given UID/SID. This method helps support protocol
modules that use PUIDs internally, as they must convert them to talk with the uplink.
"""
log.debug('(%s) _expandPUID: got uid %s', self.name, uid)
# TODO: stop hardcoding @ as separator
if '@' in uid:
if uid and '@' in uid:
if uid in self.users:
# UID exists and has a @ in it, meaning it's a PUID (orignick@counter style).
# Return this user's nick accordingly.