Ejemplo n.º 1
0
    def toXML(self, level=0, version="2.2.2"):
        structseq = ossie.parsers.prf.structSequence(id_=self.id_,
                                                     name=self.name,
                                                     mode=self.mode,
                                                     description=self.__doc__)

        for kind in self.kinds:
            structseq.add_configurationkind(ossie.parsers.prf.configurationKind(kind))

        struct = ossie.parsers.prf.struct(id_="")
        for name, attr in self.structdef.__dict__.items():
            if type(attr) is simple_property: 
                simp = ossie.parsers.prf.simple(id_=attr.id_, 
                                                type_=attr.type_,
                                                name=attr.name, 
                                                description=attr.__doc__,
                                                units=attr.units)
                struct.add_simple(simp)
        structseq.set_struct(struct)

        if self.defvalue:
            for v in self.defvalue:
                structval = ossie.parsers.prf.structValue()
                for name, attr in self.structdef.__dict__.items():
                    if type(attr) is simple_property:
                        id_=attr.id_
                        value = to_xmlvalue(attr.get(v), attr.type_)
                        structval.add_simpleref(ossie.parsers.prf.simpleRef(id_, value))
                structseq.add_structvalue(structval)

        xml = StringIO.StringIO()
        structseq.export(xml, level)
        return xml.getvalue()
Ejemplo n.º 2
0
    def toXML(self, level=0, version="2.2.2"):
        struct = ossie.parsers.prf.struct(id_=self.id_, name=self.name, mode=self.mode, description=self.__doc__)

        for kind in self.kinds:
            struct.add_configurationkind(ossie.parsers.prf.configurationKind(kind))

        for name, attr in self.structdef.__dict__.items():
            if type(attr) is simple_property:
                simp = ossie.parsers.prf.simple(
                    id_=attr.id_,
                    type_=attr.type_,
                    name=attr.name,
                    description=attr.__doc__,
                    value=to_xmlvalue(attr.defvalue, attr.type_),
                    units=attr.units,
                )
                struct.add_simple(simp)

        xml = StringIO.StringIO()
        struct.export(xml, level)
        return xml.getvalue()