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:
parent
ac7d587c49
commit
85f3bd5988
1 changed files with 79 additions and 48 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue