comparison src/memory/memory.py @ 2146:1bb9bf1b4150

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
author Goffi <goffi@goffi.org>
date Sun, 12 Feb 2017 19:08:52 +0100
parents 1d3f73e065e1
children 8b37a62336c3
comparison
equal deleted inserted replaced
2145:33c8c4973743 2146:1bb9bf1b4150
428 try: 428 try:
429 del self._entities_cache[profile] 429 del self._entities_cache[profile]
430 except KeyError: 430 except KeyError:
431 log.error(_(u"Trying to purge roster status cache for a profile not in memory: [%s]") % profile) 431 log.error(_(u"Trying to purge roster status cache for a profile not in memory: [%s]") % profile)
432 432
433 def getProfilesList(self): 433 def getProfilesList(self, clients=True, components=False):
434 return self.storage.getProfilesList() 434 """retrieve profiles list
435
436 @param clients(bool): if True return clients profiles
437 @param components(bool): if True return components profiles
438 @return (list[unicode]): selected profiles
439 """
440 if not clients and not components:
441 log.warning(_(u"requesting no profiles at all"))
442 return []
443 profiles = self.storage.getProfilesList()
444 if clients and components:
445 return sorted(profiles)
446 isComponent = self.storage.profileIsComponent
447 if clients:
448 p_filter = lambda p: not isComponent(p)
449 else:
450 p_filter = lambda p: isComponent(p)
451
452 return sorted(p for p in profiles if p_filter(p))
435 453
436 def getProfileName(self, profile_key, return_profile_keys=False): 454 def getProfileName(self, profile_key, return_profile_keys=False):
437 """Return name of profile from keyword 455 """Return name of profile from keyword
438 456
439 @param profile_key: can be the profile name or a keyword (like @DEFAULT@) 457 @param profile_key: can be the profile name or a keyword (like @DEFAULT@)