Mercurial > libervia-backend
comparison src/memory/memory.py @ 728:e07afabc4a25
plugin XEP-0050: Ad-Hoc commands first draft (answering part)
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 10 Dec 2013 17:25:31 +0100 |
parents | 04aabc3f2684 |
children | 8f50a0079769 |
comparison
equal
deleted
inserted
replaced
727:c1cd6c0c2c38 | 728:e07afabc4a25 |
---|---|
179 error(_("Trying to delete a connected profile")) | 179 error(_("Trying to delete a connected profile")) |
180 raise exceptions.NotConnectedProfileError | 180 raise exceptions.NotConnectedProfileError |
181 self.storage.deleteProfile(profile) | 181 self.storage.deleteProfile(profile) |
182 return False | 182 return False |
183 | 183 |
184 def getProfileName(self, profile_key): | 184 def getProfileName(self, profile_key, return_profile_keys = False): |
185 """return profile according to profile_key | 185 """return profile according to profile_key |
186 @param profile_key: profile name or key which can be | 186 @param profile_key: profile name or key which can be |
187 @ALL@ for all profiles | 187 @ALL@ for all profiles |
188 @DEFAULT@ for default profile | 188 @DEFAULT@ for default profile |
189 @return: requested profile name or None if it doesn't exist""" | 189 @param return_profile_keys: if True, return unmanaged profile keys (like "@ALL@"). This keys must be managed by the caller |
190 @return: requested profile name or emptry string if it doesn't exist""" | |
190 if profile_key == '@DEFAULT@': | 191 if profile_key == '@DEFAULT@': |
191 default = self.host.memory.memory_data.get('Profile_default') | 192 default = self.host.memory.memory_data.get('Profile_default') |
192 if not default: | 193 if not default: |
193 info(_('No default profile, returning first one')) # TODO: manage real default profile | 194 info(_('No default profile, returning first one')) # TODO: manage real default profile |
194 try: | 195 try: |
197 info(_('No profile exist yet')) | 198 info(_('No profile exist yet')) |
198 return "" | 199 return "" |
199 return default # FIXME: temporary, must use real default value, and fallback to first one if it doesn't exists | 200 return default # FIXME: temporary, must use real default value, and fallback to first one if it doesn't exists |
200 elif profile_key == '@NONE@': | 201 elif profile_key == '@NONE@': |
201 raise exceptions.ProfileNotSetError | 202 raise exceptions.ProfileNotSetError |
203 elif return_profile_keys and profile_key in ["@ALL@"]: | |
204 return profile_key # this value must be managed by the caller | |
202 if not self.storage.hasProfile(profile_key): | 205 if not self.storage.hasProfile(profile_key): |
203 info(_('Trying to access an unknown profile')) | 206 info(_('Trying to access an unknown profile')) |
204 return "" | 207 return "" # FIXME: raise exceptions.ProfileUnknownError here (must be well checked, this method is used in lot of places) |
205 return profile_key | 208 return profile_key |
206 | 209 |
207 def __get_unique_node(self, parent, tag, name): | 210 def __get_unique_node(self, parent, tag, name): |
208 """return node with given tag | 211 """return node with given tag |
209 @param parent: parent of nodes to check (e.g. documentElement) | 212 @param parent: parent of nodes to check (e.g. documentElement) |
709 return False | 712 return False |
710 | 713 |
711 def getProfilesList(self): | 714 def getProfilesList(self): |
712 return self.storage.getProfilesList() | 715 return self.storage.getProfilesList() |
713 | 716 |
714 def getProfileName(self, profile_key): | 717 def getProfileName(self, profile_key, return_profile_keys = False): |
715 """Return name of profile from keyword | 718 """Return name of profile from keyword |
716 @param profile_key: can be the profile name or a keywork (like @DEFAULT@) | 719 @param profile_key: can be the profile name or a keywork (like @DEFAULT@) |
717 @return: profile name or None if it doesn't exist""" | 720 @return: profile name or None if it doesn't exist""" |
718 return self.params.getProfileName(profile_key) | 721 return self.params.getProfileName(profile_key, return_profile_keys) |
719 | 722 |
720 def createProfile(self, name): | 723 def createProfile(self, name): |
721 """Create a new profile | 724 """Create a new profile |
722 @param name: Profile name | 725 @param name: Profile name |
723 """ | 726 """ |