1 # -*- encoding: utf-8 -*-
3 __author__= "Ćukasz Rekucki"
4 __date__ = "$2009-10-19 16:31:14$"
5 __doc__ = "Functions to operate on a tag-light version of WLML."
7 class LightSerializer(object):
12 def serialize(self, element):
13 handler = getattr(self, 'serialize_' + element.tag, self.identity)
14 return handler(element) + (element.tail or u'')
16 def serialize_slowo_obce(self, e):
17 return u' %%'+self.descent(e)+u'%% '
21 for child in e.iterchildren():
22 b += self.serialize(child)
25 def identity(self, e):
29 b += u' '.join((u'%s="%s"' % (attr, value) for attr,value in e.items()))
32 b += u'</' + e.tag + u'>'
36 _serializer = LightSerializer()
38 def serialize_nl(element):
39 prolog = u'' + element.text # ordinary stuff
42 for child in element.iterchildren():
43 data += _serializer.serialize(child)