quick frontend (contact list): bare_default in getCache now default to True, plus added None:

if None is used, bare_default will be used only if the entity is not in a room
This commit is contained in:
Goffi 2017-01-15 16:00:41 +01:00
commit 1a33c3389f

View file

@ -204,7 +204,7 @@ class ProfileContactList(object):
def fill(self):
handler.fill(self.profile)
def getCache(self, entity, name=None, bare_default=False):
def getCache(self, entity, name=None, bare_default=True):
"""Return a cache value for a contact
@param entity(jid.JID): entity of the contact from who we want data (resource is used if given)
@ -212,9 +212,10 @@ class ProfileContactList(object):
- if no resource is given (bare jid), the main resource is used, according to priority
- if resource is given, it is used
@param name(unicode): name the data to get, or None to get everything
@param bare_default(bool): if True and entity is a full jid, the value of bare jid
@param bare_default(bool, None): if True and entity is a full jid, the value of bare jid
will be returned if not value is found for the requested resource.
If False, None is returned if no value is found for the requested resource.
If None, bare_default will be set to False if entity is in a room, True else
@return: full cache if no name is given, or value of "name", or None
"""
# FIXME: resource handling need to be reworked
@ -247,6 +248,8 @@ class ProfileContactList(object):
try:
return cache[C.CONTACT_RESOURCES][entity.resource][name]
except KeyError:
if bare_default is None:
bare_default = not self.isRoom(entity.bare)
if not bare_default:
return None