comparison frontends/src/quick_frontend/quick_widgets.py @ 2027:666b42c957b5

quick frontend (widget): minor profiles check on widget creation
author Goffi <goffi@goffi.org>
date Mon, 08 Aug 2016 00:49:17 +0200
parents 19b9d3f8a6c7
children 6353deb1bd73
comparison
equal deleted inserted replaced
2026:cdb2591d0b8b 2027:666b42c957b5
273 self.addProfile(profiles) 273 self.addProfile(profiles)
274 elif profiles is None: 274 elif profiles is None:
275 if not self.PROFILES_ALLOW_NONE: 275 if not self.PROFILES_ALLOW_NONE:
276 raise ValueError("profiles can't have a value of None") 276 raise ValueError("profiles can't have a value of None")
277 else: 277 else:
278 if not self.PROFILES_MULTIPLE and len(profiles) != 1:
279 raise ValueError("multiple profiles are not allowed")
280 for profile in profiles: 278 for profile in profiles:
281 self.addProfile(profile) 279 self.addProfile(profile)
280 if not self.profiles:
281 raise ValueError("no profile found, use None for no profile classes")
282 282
283 @property 283 @property
284 def profile(self): 284 def profile(self):
285 assert len(self.profiles) == 1 and not self.PROFILES_MULTIPLE and not self.PROFILES_ALLOW_NONE 285 assert len(self.profiles) == 1 and not self.PROFILES_MULTIPLE and not self.PROFILES_ALLOW_NONE
286 return list(self.profiles)[0] 286 return list(self.profiles)[0]