core, frontends: getProfilesList renamed to profilesGetList + behaviour change:

- profilesGetList now handles clients and components boolean arguments, to filter profiles
    - jp: added --clients and --components options to profile/list
    - profilesGetList now returns sorted profiles
This commit is contained in:
Goffi 2017-02-12 19:08:52 +01:00
commit 85f3bd5988

View file

@ -430,8 +430,26 @@ class Memory(object):
except KeyError:
log.error(_(u"Trying to purge roster status cache for a profile not in memory: [%s]") % profile)
def getProfilesList(self):
return self.storage.getProfilesList()
def getProfilesList(self, clients=True, components=False):
"""retrieve profiles list
@param clients(bool): if True return clients profiles
@param components(bool): if True return components profiles
@return (list[unicode]): selected profiles
"""
if not clients and not components:
log.warning(_(u"requesting no profiles at all"))
return []
profiles = self.storage.getProfilesList()
if clients and components:
return sorted(profiles)
isComponent = self.storage.profileIsComponent
if clients:
p_filter = lambda p: not isComponent(p)
else:
p_filter = lambda p: isComponent(p)
return sorted(p for p in profiles if p_filter(p))
def getProfileName(self, profile_key, return_profile_keys=False):
"""Return name of profile from keyword