How to use the cmake.scripts.dom.tag function in cmake

To help you get started, we’ve selected a few cmake examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ryppl / ryppl / cmake / scripts / dom.py View on Github external
class PrettyElementTree(ElementTree.ElementTree):
    def __str__(self):
        x = deepcopy(self)
        indent(x.getroot())
        out = StringIO()
        x.write(out, encoding='utf-8', xml_declaration=True)
        return out.getvalue()

def xml_document(t):
    e = t.element if isinstance(t,tag) else t
    return PrettyElementTree(e)

if __name__ == '__main__':
    
    _ = tag
    print _.CarrierCode

    print _.RequestHeader[
                _.AccountNumber[ 33 ]
              , (_.MeterNumber[ 44 ]
              , _.CarrierCode[ 'FDXG' ])
            ]
    
    print xml_document(
            _.RequestHeader[
                _.AccountNumber[ 33 ]
              , _.MeterNumber[ 44 ]
              , _.CarrierCode[ 'FDXG' ]
            ])

    print xml_document(_('checkout-shopping-cart', xmlns="http://checkout.google.com/schema/2"))
github ryppl / ryppl / cmake / scripts / dom.py View on Github external
def xml_document(t):
    e = t.element if isinstance(t,tag) else t
    return PrettyElementTree(e)
github ryppl / ryppl / cmake / scripts / dom.py View on Github external
def __getattr__(self, tagname):
        return tag(self.__name + ':' + tagname)
github ryppl / ryppl / cmake / scripts / dom.py View on Github external
def __iter__(self):
        return iter(self._children)
    
    @property
    def element(self):
        return self.__element

    def indent(self):
        indent(self.element)

class dashmetatag(metatag):
    def __getattr__(self, name):
        return tag(name.replace('_','-'))
    
class dashtag(tag):
    __metaclass__ = dashmetatag
    

class PrettyElementTree(ElementTree.ElementTree):
    def __str__(self):
        x = deepcopy(self)
        indent(x.getroot())
        out = StringIO()
        x.write(out, encoding='utf-8', xml_declaration=True)
        return out.getvalue()

def xml_document(t):
    e = t.element if isinstance(t,tag) else t
    return PrettyElementTree(e)

if __name__ == '__main__':
github ryppl / ryppl / cmake / scripts / dom.py View on Github external
    @staticmethod
    def _flatten_append(l, x):
        if x is None:
            pass
        elif isinstance(x, tag):
            l.append(x.element)
        elif isinstance(x, _Element):
            l.append(x)
        elif isinstance(x,list) or isinstance(x,tuple):
            for y in x:
                tag._flatten_append(l, y)
        else:
            if len(l):
                l[-1].tail = (l[-1].tail or u'') + unicode(x)
            else:
                l.text =  (l.text or u'') + unicode(x)
github ryppl / ryppl / cmake / scripts / dom.py View on Github external
def __getattr__(self, name):
        return tag(name)
github ryppl / ryppl / cmake / scripts / dom.py View on Github external
print _.CarrierCode

    print _.RequestHeader[
                _.AccountNumber[ 33 ]
              , (_.MeterNumber[ 44 ]
              , _.CarrierCode[ 'FDXG' ])
            ]
    
    print xml_document(
            _.RequestHeader[
                _.AccountNumber[ 33 ]
              , _.MeterNumber[ 44 ]
              , _.CarrierCode[ 'FDXG' ]
            ])

    print xml_document(_('checkout-shopping-cart', xmlns="http://checkout.google.com/schema/2"))

    print xml_document(dashtag.checkout_shopping_cart(xmlns="http://checkout.google.com/schema/2"))
    
    t = _.text[ 'here is some ', 'text ', _.b['boldly ', 32], ' under rocks' ]
    print t
    assert str(t) == str(
        _.text[ None, 'here is some ', None, 'text ', _.b['boldly ', 32], ' under rocks', None ])

    r = _.text[ 'here is some ', 'text ', _.b['boldly ', 32], ' under rocks' ]
    r <<= _.i['fu']
    print r
    
    print xmlns.dc.name['somebody']
github ryppl / ryppl / cmake / scripts / dom.py View on Github external
def __getattr__(self, name):
        return tag(name.replace('_','-'))