def decode(self, value=None): if value in ('', None): return None else: try: return int(value) except ValueError: raise valueInvalidSyntax, valueInvalidSyntax('Value of {!r} must be an int (is {!r}).'.format(self.property_name, value)), sys.exc_info()[2]
def encode(cls, value=None): if value: try: values = [v.split() for v in value] return [cls._weekdays.index(w) * 24 + int(h.split('-', 1)[0]) for w, h in values] except (IndexError, ValueError): raise valueInvalidSyntax, valueInvalidSyntax('One or more entries in sambaLogonHours have invalid syntax.'), sys.exc_info()[2] else: return value