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

classes: clean up _expandPUID

Also make the logging less noisy.
This commit is contained in:
James Lu 2019-12-22 22:11:31 -08:00
parent b1b14dfb55
commit b495cb4c5e

View File

@ -1686,26 +1686,17 @@ class PyLinkNetworkCoreWithUtils(PyLinkNetworkCore):
uid, nick)
self.call_hooks([self.sid, 'SAVE', {'target': uid}])
def _expandPUID(self, uid):
def _expandPUID(self, entityid):
"""
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 uid and isinstance(uid, str) 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.
nick = self.users[uid].nick
log.debug('(%s) Mangling target PUID %s to nick %s', self.name, uid, nick)
return nick
elif uid in self.servers:
# Ditto for servers
sname = self.servers[uid].name
log.debug('(%s) Mangling target PSID %s to server name %s', self.name, uid, sname)
return sname
return uid # Regular UID, no change
if isinstance(entityid, str) and '@' in entityid:
name = self.get_friendly_name(entityid)
log.debug('(%s) _expandPUID: mangling pseudo ID %s to %s', self.name, entityid, name)
return name
return entityid # Regular UID/SID, no change
def wrap_message(self, source, target, text):
"""