comparison src/memory/params.py @ 1590:ab54af2a9ab2

core (memory): fixed a case where getProfileName was returning an empty string instead of raising an errror
author Goffi <goffi@goffi.org>
date Sat, 14 Nov 2015 19:18:10 +0100
parents 698d6755d62a
children a3d0cfa5b7a6
comparison
equal deleted inserted replaced
1589:add1a6c8c594 1590:ab54af2a9ab2
192 @param profile_key: profile name or key which can be 192 @param profile_key: profile name or key which can be
193 C.PROF_KEY_ALL for all profiles 193 C.PROF_KEY_ALL for all profiles
194 C.PROF_KEY_DEFAULT for default profile 194 C.PROF_KEY_DEFAULT for default profile
195 @param return_profile_keys: if True, return unmanaged profile keys (like C.PROF_KEY_ALL). This keys must be managed by the caller 195 @param return_profile_keys: if True, return unmanaged profile keys (like C.PROF_KEY_ALL). This keys must be managed by the caller
196 @return: requested profile name 196 @return: requested profile name
197 @raise exceptions.ProfileUnknownError if profile doesn't exists 197 @raise exceptions.ProfileUnknownError: profile doesn't exists
198 @raise exceptions.ProfileNotSetError: if C.PROF_KEY_NONE is used
198 """ 199 """
199 if profile_key == '@DEFAULT@': 200 if profile_key == '@DEFAULT@':
200 default = self.host.memory.memory_data.get('Profile_default') 201 default = self.host.memory.memory_data.get('Profile_default')
201 if not default: 202 if not default:
202 log.info(_('No default profile, returning first one')) # TODO: manage real default profile 203 log.info(_('No default profile, returning first one')) # TODO: manage real default profile
203 try: 204 try:
204 default = self.host.memory.memory_data['Profile_default'] = self.storage.getProfilesList()[0] 205 default = self.host.memory.memory_data['Profile_default'] = self.storage.getProfilesList()[0]
205 except IndexError: 206 except IndexError:
206 log.info(_('No profile exist yet')) 207 log.info(_('No profile exist yet'))
207 return "" 208 raise exceptions.ProfileUnknownError
208 return default # FIXME: temporary, must use real default value, and fallback to first one if it doesn't exists 209 return default # FIXME: temporary, must use real default value, and fallback to first one if it doesn't exists
209 elif profile_key == C.PROF_KEY_NONE: 210 elif profile_key == C.PROF_KEY_NONE:
210 raise exceptions.ProfileNotSetError 211 raise exceptions.ProfileNotSetError
211 elif return_profile_keys and profile_key in [C.PROF_KEY_ALL]: 212 elif return_profile_keys and profile_key in [C.PROF_KEY_ALL]:
212 return profile_key # this value must be managed by the caller 213 return profile_key # this value must be managed by the caller