comparison src/memory/params.py @ 1460:c7fd121a6180

core: getProfileName no raise ProfileUnknownError + minor doc fixes
author Goffi <goffi@goffi.org>
date Sun, 16 Aug 2015 00:41:58 +0200
parents 3265a2639182
children ac522c4dab0e
comparison
equal deleted inserted replaced
1459:4c4f88d7b156 1460:c7fd121a6180
184 184
185 @param profile_key: profile name or key which can be 185 @param profile_key: profile name or key which can be
186 @ALL@ for all profiles 186 @ALL@ for all profiles
187 @DEFAULT@ for default profile 187 @DEFAULT@ for default profile
188 @param return_profile_keys: if True, return unmanaged profile keys (like "@ALL@"). This keys must be managed by the caller 188 @param return_profile_keys: if True, return unmanaged profile keys (like "@ALL@"). This keys must be managed by the caller
189 @return: requested profile name or emptry string if it doesn't exist""" 189 @return: requested profile name
190 @raise exceptions.ProfileUnknownError if profile doesn't exists
191 """
190 if profile_key == '@DEFAULT@': 192 if profile_key == '@DEFAULT@':
191 default = self.host.memory.memory_data.get('Profile_default') 193 default = self.host.memory.memory_data.get('Profile_default')
192 if not default: 194 if not default:
193 log.info(_('No default profile, returning first one')) # TODO: manage real default profile 195 log.info(_('No default profile, returning first one')) # TODO: manage real default profile
194 try: 196 try:
201 raise exceptions.ProfileNotSetError 203 raise exceptions.ProfileNotSetError
202 elif return_profile_keys and profile_key in ["@ALL@"]: 204 elif return_profile_keys and profile_key in ["@ALL@"]:
203 return profile_key # this value must be managed by the caller 205 return profile_key # this value must be managed by the caller
204 if not self.storage.hasProfile(profile_key): 206 if not self.storage.hasProfile(profile_key):
205 log.error(_(u'Trying to access an unknown profile (%s)') % profile_key) 207 log.error(_(u'Trying to access an unknown profile (%s)') % profile_key)
206 return "" # FIXME: raise exceptions.ProfileUnknownError here (must be well checked, this method is used in lot of places) 208 raise exceptions.ProfileUnknownError
207 return profile_key 209 return profile_key
208 210
209 def __get_unique_node(self, parent, tag, name): 211 def __get_unique_node(self, parent, tag, name):
210 """return node with given tag 212 """return node with given tag
211 @param parent: parent of nodes to check (e.g. documentElement) 213 @param parent: parent of nodes to check (e.g. documentElement)