plugin XEP-0050: Ad-Hoc commands first draft (answering part)
This commit is contained in:
parent
05bf17c777
commit
f7efb167c8
1 changed files with 381 additions and 5 deletions
|
|
@ -181,12 +181,13 @@ class Params(object):
|
|||
self.storage.deleteProfile(profile)
|
||||
return False
|
||||
|
||||
def getProfileName(self, profile_key):
|
||||
def getProfileName(self, profile_key, return_profile_keys = False):
|
||||
"""return profile according to profile_key
|
||||
@param profile_key: profile name or key which can be
|
||||
@ALL@ for all profiles
|
||||
@DEFAULT@ for default profile
|
||||
@return: requested profile name or None if it doesn't exist"""
|
||||
@param return_profile_keys: if True, return unmanaged profile keys (like "@ALL@"). This keys must be managed by the caller
|
||||
@return: requested profile name or emptry string if it doesn't exist"""
|
||||
if profile_key == '@DEFAULT@':
|
||||
default = self.host.memory.memory_data.get('Profile_default')
|
||||
if not default:
|
||||
|
|
@ -199,9 +200,11 @@ class Params(object):
|
|||
return default # FIXME: temporary, must use real default value, and fallback to first one if it doesn't exists
|
||||
elif profile_key == '@NONE@':
|
||||
raise exceptions.ProfileNotSetError
|
||||
elif return_profile_keys and profile_key in ["@ALL@"]:
|
||||
return profile_key # this value must be managed by the caller
|
||||
if not self.storage.hasProfile(profile_key):
|
||||
info(_('Trying to access an unknown profile'))
|
||||
return ""
|
||||
return "" # FIXME: raise exceptions.ProfileUnknownError here (must be well checked, this method is used in lot of places)
|
||||
return profile_key
|
||||
|
||||
def __get_unique_node(self, parent, tag, name):
|
||||
|
|
@ -711,11 +714,11 @@ class Memory(object):
|
|||
def getProfilesList(self):
|
||||
return self.storage.getProfilesList()
|
||||
|
||||
def getProfileName(self, profile_key):
|
||||
def getProfileName(self, profile_key, return_profile_keys = False):
|
||||
"""Return name of profile from keyword
|
||||
@param profile_key: can be the profile name or a keywork (like @DEFAULT@)
|
||||
@return: profile name or None if it doesn't exist"""
|
||||
return self.params.getProfileName(profile_key)
|
||||
return self.params.getProfileName(profile_key, return_profile_keys)
|
||||
|
||||
def createProfile(self, name):
|
||||
"""Create a new profile
|
||||
|
|
|
|||
Loading…
Reference in a new issue