Esempio n. 1
0
 def read_hole(self):
     type = self.read_uint32()
     if type == 0:
         return document.dot(self.read_item())
     if type == 1:
         length = self.read_uint32()
         blob = []
         for i in range(length):
             blob.append(self.read_item())
         return document.star(blob)
Esempio n. 2
0
def test():
    import zlib
    root = document.element('root', [
        document.star([
            'huh',
        ])
    ])
    pre = len(root)
    s = save_to_string(root)
    print "string length=%i, compressed=%i" % (len(s), len(zlib.compress(s)))
    root = load_from_string(s)
    assert len(root) == pre
    assert root.name == 'root'
    assert root.holes[0].a == ['huh']