Mercurial > libervia-backend
changeset 1298:e2f71b715708 frontends_multi_profiles
core: better use of C.bool: C.bool only accept basestring subclasses and return the associated constant, C.boolConst return the associated constant for a boolean value
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 06 Feb 2015 18:46:26 +0100 (2015-02-06) |
parents | 0541cb64217e |
children | 3360074a2f00 |
files | src/core/constants.py |
diffstat | 1 files changed, 7 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/constants.py Mon Jan 26 02:03:16 2015 +0100 +++ b/src/core/constants.py Fri Feb 06 18:46:26 2015 +0100 @@ -219,14 +219,12 @@ @classmethod def bool(cls, value): - """@return: bool value for any type""" - if isinstance(value, str) or isinstance(value, unicode): # dbus.String is unicode but not str - return value.lower() == cls.BOOL_TRUE - return bool(value) + """@return (bool): bool value for associated constant""" + assert isinstance(value, basestring) + return value.lower() == cls.BOOL_TRUE @classmethod - def str(cls, value): - """@return: str text value for any type""" - if isinstance(value, bool): - return cls.BOOL_TRUE if value else cls.BOOL_FALSE - return str(value) + def boolConst(cls, value): + """@return (str): constant associated to bool value""" + assert isinstance(value, bool) + return cls.BOOL_TRUE if value else cls.BOOL_FALSE