Exemplo n.º 1
0
def process_attribute(ctx, a):
    if a.ref is not None:
        t = get_type(ctx, a.ref)
        return t.type.get_type_name(), t

    if a.type is not None:
        t = get_type(ctx, a.type)

    elif a.simple_type is not None:
        t = process_simple_type(ctx, a.simple_type, a.name)

    else:
        raise Exception("dunno attr")

    if t is None:
        raise ValueError(a, 'not found')

    kwargs = {}
    if a.default is not None:
        kwargs['default'] = _prot.from_string(t, a.default)

    if len(kwargs) > 0:
        t = t.customize(**kwargs)
        ctx.debug2("t = t.customize(**%r)" % kwargs)
    return (a.name, XmlAttribute(t))
Exemplo n.º 2
0
    def process_attribute(self, a):
        if a.ref is not None:
            t = self.get_type(a.ref)
            return t.type.get_type_name(), t

        if a.type is not None and a.simple_type is not None:
            raise ValueError(a, "Both type and simple_type are defined.")

        elif a.type is not None:
            t = self.get_type(a.type)

            if t is None:
                raise ValueError(a, 'type %r not found' % a.type)

        elif a.simple_type is not None:
            t = self.process_simple_type(a.simple_type, a.name)

            if t is None:
                raise ValueError(a, 'simple type %r not found' % a.simple_type)

        else:
            raise Exception("dunno attr")

        kwargs = {}
        if a.default is not None:
            kwargs['default'] = _prot.from_string(t, a.default)

        if len(kwargs) > 0:
            t = t.customize(**kwargs)
            self.debug2("t = t.customize(**%r)" % kwargs)
        return a.name, XmlAttribute(t)
Exemplo n.º 3
0
 class ProductEdition(ComplexModel):
     __namespace__ = tns
     id = XmlAttribute(Uuid)
     if custom_root:
         name = XmlData(Uuid)
     else:
         name = XmlData(Unicode)
Exemplo n.º 4
0
        class Action(ComplexModel):
            class Attributes(ComplexModel.Attributes):
                sub_ns = "SOME_NS"
                sub_name = "Action"

            data = XmlData(Unicode)
            must_understand = XmlAttribute(Unicode)
Exemplo n.º 5
0
        class Release(ComplexModel):
            __namespace__ = "http://usefulinc.com/ns/doap#"

            _type_info = [
                ('about', XmlAttribute(Unicode,
                             ns="http://www.w3.org/1999/02/22-rdf-syntax-ns#")),
            ]
Exemplo n.º 6
0
        class Project(ComplexModel):
            __namespace__ = "http://usefulinc.com/ns/doap#"

            _type_info = [
                ('about', XmlAttribute(Unicode,
                             ns="http://www.w3.org/1999/02/22-rdf-syntax-ns#")),
                ('release', Release.customize(max_occurs=float('inf'))),
            ]
Exemplo n.º 7
0
        class SomeGuy(ComplexModel):
            __namespace__ = tns

            name = XmlAttribute(Unicode(default="aa"))
Exemplo n.º 8
0
        class SomeGuy(ComplexModel):
            __namespace__ = tns

            bald = XmlAttribute(Boolean(default=True))
Exemplo n.º 9
0
 class C(ComplexModel):
     __namespace__ = "aa"
     foo = XmlAttribute(M(Unicode))
Exemplo n.º 10
0
 class Product(ComplexModel):
     __namespace__ = tns
     id = XmlAttribute(Uuid)
     edition = ProductEdition
Exemplo n.º 11
0
 class PacketAttribute(ComplexModel):
     __namespace__ = 'myns'
     Data = XmlAttribute(ByteArray, use='required')
Exemplo n.º 12
0
 class SummaryStatsOfDouble(ComplexModel):
     _type_info = [('Min', XmlAttribute(Integer, use='required')),
                   ('Max', XmlAttribute(Integer, use='required')),
                   ('Avg', XmlAttribute(Integer, use='required'))]
Exemplo n.º 13
0
 class C(ComplexModel):
     a = XmlData(Unicode)
     b = XmlAttribute(Unicode)
Exemplo n.º 14
0
 class Action (ComplexModel):
     data = XmlAttribute(M(Unicode))
Exemplo n.º 15
0
 class C(ComplexModel):
     bar = XmlAttribute(M(Unicode))
Exemplo n.º 16
0
 class C(ComplexModel):
     __namespace__ = "aa"
     a = XmlAttribute(Integer)
     b = XmlAttribute(Integer(sub_name="bb"))
     c = XmlAttribute(Integer(sub_ns="cc"))
     d = XmlAttribute(Integer(sub_ns="dd", sub_name="dd"))
Exemplo n.º 17
0
 class SomeClass(ComplexModel):
     a = XmlAttribute(Integer(ge=4))
Exemplo n.º 18
0
 class DeviceEntity(ComplexModel):
     token = XmlAttribute(Unicode, use='required')
Exemplo n.º 19
0
 class DigitalInput(DeviceEntity):
     IdleState = XmlAttribute(Unicode)
Exemplo n.º 20
0
        class SomeClass(TableModel):
            __tablename__ = 'some_class'
            __table_args__ = {"sqlite_autoincrement": True}

            i = XmlAttribute(Integer32(pk=True))
            s = XmlData(Unicode(64))
Exemplo n.º 21
0
 class Product(ComplexModel):
     __namespace__ = tns
     id = XmlAttribute(Uuid)
     edition = ProductEdition
     sample = XmlAttribute(Unicode, attribute_of='edition')
Exemplo n.º 22
0
 class CM(ComplexModel):
     i = Integer
     s = String
     a = XmlAttribute(String)
Exemplo n.º 23
0
        class Product(ComplexModel):
            __namespace__ = 'some_ns'

            id = XmlAttribute(Uuid)
            edition = Unicode
Exemplo n.º 24
0
 class ProductEdition(ComplexModel):
     __namespace__ = tns
     id = XmlAttribute(Uuid)
     name = XmlData(Unicode)