def to_parent_element(cls, value, tns, parent_elt, name='retval'): format = getattr(cls.Attributes, 'format', None) if format: try: formated_date = datetime.datetime.strftime(value, format) except TypeError: raise Exception("Not able to format Date [%s] in [%s] format" % (value, format)) SimpleType.to_parent_element(formated_date, tns, parent_elt, name) else: SimpleType.to_parent_element(value.isoformat(), tns, parent_elt, name)
def __new__(cls, *args, **kwargs): assert len(args) <= 1 if len(args) == 1: kwargs['max_len'] = args[0] retval = SimpleType.__new__(cls, ** kwargs) return retval
def to_parent_element(cls, value, tns, parent_elt, name='retval'): SimpleType.to_parent_element(str(bool(value)).lower(), tns, parent_elt, name)
def to_parent_element(cls, value, tns, parent_elt, name='retval'): SimpleType.to_parent_element(str(value), tns, parent_elt, name)
def to_parent_element(cls, value, tns, parent_elt, name='retval'): SimpleType.to_parent_element(value.isoformat('T'), tns, parent_elt, name)
def to_parent_element(cls, value, tns, parent_elt, name='retval'): if not isinstance(value, unicode): value = unicode(value, string_encoding) SimpleType.to_parent_element(value, tns, parent_elt, name)
def is_default(cls): return ( SimpleType.is_default(cls) and cls.Attributes.min_len == String.Attributes.min_len and cls.Attributes.max_len == String.Attributes.max_len and cls.Attributes.pattern == String.Attributes.pattern)
def to_parent_element(cls, value, tns, parent_elt, name='retval'): duration = XmlDuration.parse(value) SimpleType.to_parent_element(str(duration), tns, parent_elt, name)