Esempio n. 1
0
 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)
Esempio n. 2
0
    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
Esempio n. 3
0
 def to_parent_element(cls, value, tns, parent_elt, name='retval'):
     SimpleType.to_parent_element(str(bool(value)).lower(), tns, parent_elt, name)
Esempio n. 4
0
 def to_parent_element(cls, value, tns, parent_elt, name='retval'):
     SimpleType.to_parent_element(str(value), tns, parent_elt, name)
Esempio n. 5
0
 def to_parent_element(cls, value, tns, parent_elt, name='retval'):
     SimpleType.to_parent_element(value.isoformat('T'), tns, parent_elt, name)
Esempio n. 6
0
    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)
Esempio n. 7
0
 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)
Esempio n. 8
0
 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)
Esempio n. 9
0
 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)