def test_normal_c14n(test): try: print( "-----8<----------8<----------8<----------8<----------8<----------8<----- test_normal_c14n()" ) print("First Object:\n" + repr(test) + "\n\n") serialized = pyxser.serialize_c14n(obj=test, depth=0, com=0) print("Serilized Object:\n" + serialized) print("First Object:\n" + repr(test) + "\n\n") print("Serilized Object Validation:\n", \ pyxser.validate_c14n(obj = serialized, enc = "utf-8"), \ pyxser.validate_c14n_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8") print("Unserialized Object:\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize_c14n_strict(obj=test, depth=0, com=0) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", pyxser.validate_c14n(obj=serialized, enc="utf-8")) print("First Object:\n" + repr(test) + "\n\n") pyxser.xmlcleanup() except Exception: print("-" * 60) traceback.print_exc(file=sys.stdout) print("-" * 60)
def test_normal(test): try: serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 2) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 3) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 4) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 5) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 0) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") pyxser.xmlcleanup() except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60
def test_all(test): try: serialized = pyxser.serialize(obj=test, enc="utf-8", typemap=test_typemap_map, selector=sel) pyxser.validate(obj=serialized, enc="utf-8") pyxser.validate_dtd(obj=serialized, enc="utf-8") unserialized = pyxser.unserialize(obj=serialized, enc="utf-8") serialized = pyxser.serialize_c14n(obj=test, depth=0, com=0) pyxser.validate_c14n(obj=serialized, enc="utf-8") pyxser.validate_c14n_dtd(obj=serialized, enc="utf-8") serialized = pyxser.u_serialize(obj=test, enc="utf-8", typemap=test_typemap_map, selector=sel) pyxser.u_validate(obj=serialized, enc="utf-8") pyxser.u_validate_dtd(obj=serialized, enc="utf-8") unserialized = pyxser.u_unserialize(obj=serialized, enc="utf-8") serialized = pyxser.u_serialize_c14n(obj=test, depth=0, com=0) pyxser.u_validate_c14n(obj=serialized, enc="utf-8") pyxser.u_validate_c14n_dtd(obj=serialized, enc="utf-8") pyxser.getdtd() pyxser.getdtd_c14n() pyxser.xmlcleanup() except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60
def test_all(test): try: serialized = pyxser.serialize(obj = test, enc = "utf-8", typemap = test_typemap_map, selector = sel) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False) serialized = pyxser.serialize_c14n(obj = test, depth = 0, com = 0) pyxser.validate_c14n(obj = serialized, enc = "utf-8") pyxser.validate_c14n_dtd(obj = serialized, enc = "utf-8") serialized = pyxser.u_serialize(obj = test, enc = "utf-8", typemap = test_typemap_map, selector = sel) pyxser.u_validate(obj = serialized, enc = "utf-8") pyxser.u_validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8", cinit = False) serialized = pyxser.u_serialize_c14n(obj = test, depth = 0, com = 0) pyxser.u_validate_c14n(obj = serialized, enc = "utf-8") pyxser.u_validate_c14n_dtd(obj = serialized, enc = "utf-8") pyxser.getdtd() pyxser.getdtd_c14n() pyxser.xmlcleanup() except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60
def test_unicode(test): try: serialized = pyxser.u_serialize(obj = test, enc = "utf-8", depth = 2) pyxser.u_validate(obj = serialized, enc = "utf-8") pyxser.u_validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8") serialized = pyxser.u_serialize(obj = test, enc = "utf-8", depth = 3) pyxser.u_validate(obj = serialized, enc = "utf-8") pyxser.u_validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8") serialized = pyxser.u_serialize(obj = test, enc = "utf-8", depth = 4) pyxser.u_validate(obj = serialized, enc = "utf-8") pyxser.u_validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8") serialized = pyxser.u_serialize(obj = test, enc = "utf-8", depth = 5) pyxser.u_validate(obj = serialized, enc = "utf-8") pyxser.u_validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8") serialized = pyxser.u_serialize(obj = test, enc = "utf-8", depth = 0) pyxser.u_validate(obj = serialized, enc = "utf-8") pyxser.u_validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8") pyxser.xmlcleanup() except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60
def test_unicode_c14n(test): try: print "-----8<----------8<----------8<----------8<----------8<----------8<----- test_unicode_c14n()" serialized = pyxser.u_serialize_c14n(obj=test, depth=0, com=1) print "Serilized Object:\n" + serialized.encode("ascii") print "First Object:\n" + repr(test) + "\n\n" print "Serilized Object Validation:\n", \ pyxser.u_validate_c14n(obj = serialized, enc = "ascii"), \ pyxser.u_validate_c14n_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.u_unserialize(obj=serialized, enc="ascii") print "Unserialized Object:\n" + repr(unserialized) + "\n\n" serialized = pyxser.u_serialize_c14n_strict(obj=test, depth=0, com=0) print "Serilized Object:\n" + serialized.encode("ascii") print "Serilized Object Validation:\n", pyxser.u_validate_c14n( obj=serialized, enc="ascii") print "First Object:\n" + repr(test) + "\n\n" pyxser.xmlcleanup() except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60
def test_normal(test): try: serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 2) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False) serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 3) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False) serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 4) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False) serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 5) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False) serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 0) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False) pyxser.xmlcleanup() except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60
def test_unicode(test): try: serialized = pyxser.u_serialize(obj = test, enc = "utf-8", depth = 2) pyxser.u_validate(obj = serialized, enc = "utf-8") pyxser.u_validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8", cinit = False) serialized = pyxser.u_serialize(obj = test, enc = "utf-8", depth = 3) pyxser.u_validate(obj = serialized, enc = "utf-8") pyxser.u_validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8", cinit = False) serialized = pyxser.u_serialize(obj = test, enc = "utf-8", depth = 4) pyxser.u_validate(obj = serialized, enc = "utf-8") pyxser.u_validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8", cinit = False) serialized = pyxser.u_serialize(obj = test, enc = "utf-8", depth = 5) pyxser.u_validate(obj = serialized, enc = "utf-8") pyxser.u_validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8", cinit = False) serialized = pyxser.u_serialize(obj = test, enc = "utf-8", depth = 0) pyxser.u_validate(obj = serialized, enc = "utf-8") pyxser.u_validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8", cinit = False) pyxser.xmlcleanup() except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60
def main(): another = testpkg.sample.TestAnotherObject() another.first_element = 123 another.second_element = 456 other = testpkg.sample.TestAnotherObject() other.first_element = complex(5.82, 3.99) other.second_element = "cdf" thisa = testpkg.sample.TestAnotherObject() thisa.first_element = "xyz" thisa.second_element = complex(7.81, 2.01) thisb = testpkg.sample.TestAnotherObject() thisb.first_element = "456" thisb.second_element = "789" thisc = testpkg.sample.TestAnotherObject() thisc.first_element = "XXX" thisc.second_element = complex(32.1, 33.1) test = testpkg.sample.ParentObject("hola", "chao", 2354345L) test.child("hi", 4.5, 2354) test.nested("holahola", 345, "hola") test.subnested(other) another.dyn_prop1 = thisa test.dyn_prop1 = [u'holá', u'chaó', another] test.dyn_prop2 = (u'hol`', u'sïn', 'trip', other) test.dyn_prop3 = { u'sáludó1': u'hólà', u'sàludà2': u'chäó', u'sáludò4': u'gòódbye', u'saludo5': thisc } test.dyn_prop4 = u'sómé tèxtè ïñ Unicodè' test.dyn_prop5 = u'Añother Texé Iñ ÜnìcóDËc' test.dyn_prop6 = 1.5 test.dyn_prop7 = 1000 try: crawl = 0 while crawl <= 100000: test_normal(test) test_normal_c14n(test) test_unicode(test) test_unicode_c14n(test) test_typemap(test) pyxser.getdtd() pyxser.getdtd_c14n() pyxser.getxsd() pyxser.getxsd_c14n() pyxser.xmlcleanup() if (crawl % 1000) == 0: print "cicle: ", crawl crawl += 1 except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60
def test_unicode(test): try: print "-----8<----------8<----------8<----------8<----------8<----------8<----- test_unicode()" print "First Object:\n" + repr(test) + "\n\n" serialized = pyxser.u_serialize(obj=test, enc="ascii", depth=2) print "Serilized Object:\n", serialized.encode("ascii") print "Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "ascii"), \ pyxser.u_validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.u_unserialize(obj=serialized, enc="ascii") print "Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n" serialized = pyxser.u_serialize(obj=test, enc="ascii", depth=3) print "Serilized Object:\n" + serialized.encode("ascii") print "Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "ascii"), \ pyxser.u_validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.u_unserialize(obj=serialized, enc="ascii") print "Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n" serialized = pyxser.u_serialize(obj=test, enc="ascii", depth=4) print "Serilized Object:\n" + serialized.encode("ascii") print "Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "ascii"), \ pyxser.u_validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.u_unserialize(obj=serialized, enc="ascii") print "Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n" serialized = pyxser.u_serialize(obj=test, enc="ascii", depth=5) print "Serilized Object:\n" + serialized.encode("ascii") print "Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "ascii"), \ pyxser.u_validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.u_unserialize(obj=serialized, enc="ascii") print "Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n" serialized = pyxser.u_serialize(obj=test, enc="ascii", depth=0, cinit=False) print "Serilized Object:\n" + serialized.encode("ascii") print "Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "ascii"), \ pyxser.u_validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.u_unserialize(obj=serialized, enc="ascii", typemap={}, cinit=False) print "Unserialized Object (d.0):\n" + repr(unserialized) + "\n\n" pyxser.xmlcleanup() except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60
def test_unicode(test): try: print( "-----8<----------8<----------8<----------8<----------8<----------8<----- test_unicode()" ) print("First Object:\n" + repr(test) + "\n\n") serialized = pyxser.u_serialize(obj=test, enc="utf-8", depth=2) print("Serilized Object:\n", serialized.encode("latin1")) print("Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "utf-8"), \ pyxser.u_validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.u_unserialize(obj=serialized, enc="utf-8") print("Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n") serialized = pyxser.u_serialize(obj=test, enc="utf-8", depth=3) print("Serilized Object:\n" + serialized.encode("latin1")) print("Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "utf-8"), \ pyxser.u_validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.u_unserialize(obj=serialized, enc="utf-8") print("Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n") serialized = pyxser.u_serialize(obj=test, enc="utf-8", depth=4) print("Serilized Object:\n" + serialized.encode("latin1")) print("Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "utf-8"), \ pyxser.u_validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.u_unserialize(obj=serialized, enc="utf-8") print("Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n") serialized = pyxser.u_serialize(obj=test, enc="utf-8", depth=5) print("Serilized Object:\n" + serialized.encode("latin1")) print("Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "utf-8"), \ pyxser.u_validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.u_unserialize(obj=serialized, enc="utf-8") print("Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n") serialized = pyxser.u_serialize(obj=test, enc="utf-8", depth=0) print("Serilized Object:\n" + serialized.encode("latin1")) print("Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "utf-8"), \ pyxser.u_validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.u_unserialize(obj=serialized, enc="utf-8", cinit=False) print("Unserialized Object (d.0):\n" + repr(unserialized) + "\n\n") pyxser.xmlcleanup() except Exception: print("-" * 60) traceback.print_exc(file=sys.stdout) print("-" * 60)
def test_selector(test): try: print "-----8<----------8<----------8<----------8<----------8<----------8<----- test_selector()" print "First Object:\n" + repr(test) + "\n\n" x = sel(test) print repr(x) serialized = pyxser.serialize(obj = test, enc = "utf-16", depth = 2, selector = sel) print "Serilized Object:\n", serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-16"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-16") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-16") print "Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj = test, enc = "utf-16", depth = 3, selector = sel) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-16"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-16") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-16") print "Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj = test, enc = "utf-16", depth = 4, selector = sel) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-16"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-16") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-16") print "Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj = test, enc = "utf-16", depth = 5, selector = sel) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-16"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-16") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-16") print "Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj = test, enc = "utf-16", depth = 0, selector = sel) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-16"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-16") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-16", cinit = False) print "Unserialized Object (d.0):\n" + repr(unserialized) + "\n\n" pyxser.xmlcleanup() except Exception, e: print "-" * 60 print e traceback.print_exc(file=sys.stdout) print "-" * 60
def test_selector(test): try: print "-----8<----------8<----------8<----------8<----------8<----------8<----- test_selector()" print "First Object:\n" + repr(test) + "\n\n" x = sel(test) print repr(x) serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 2, selector = sel) print "Serilized Object:\n", serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "ascii"), \ pyxser.validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.unserialize(obj = serialized, enc = "ascii") print "Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 3, selector = sel) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "ascii"), \ pyxser.validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.unserialize(obj = serialized, enc = "ascii") print "Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 4, selector = sel) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "ascii"), \ pyxser.validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.unserialize(obj = serialized, enc = "ascii") print "Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 5, selector = sel) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "ascii"), \ pyxser.validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.unserialize(obj = serialized, enc = "ascii") print "Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 0, selector = sel) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "ascii"), \ pyxser.validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.unserialize(obj = serialized, enc = "ascii") print "Unserialized Object (d.0):\n" + repr(unserialized) + "\n\n" pyxser.xmlcleanup() except Exception, e: print "-" * 60 print e traceback.print_exc(file=sys.stdout) print "-" * 60
def test_normal(test): try: print( "-----8<----------8<----------8<----------8<----------8<----------8<----- test_normal()" ) print("First Object:\n" + repr(test) + "\n\n") serialized = pyxser.serialize(obj=test, enc="utf-8", depth=100) print("Serilized Object:%s\n" % (serialized)) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8") print("Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize(obj=test, enc="utf-8", depth=3) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8") print("Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize(obj=test, enc="utf-8", depth=4) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8") print("Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize(obj=test, enc="utf-8", depth=5) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8") print("Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize(obj=test, enc="utf-8", depth=0) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8", cinit=False) print("Unserialized Object (d.6):\n" + repr(unserialized) + "\n\n") pyxser.xmlcleanup() except Exception: print("-" * 60) traceback.print_exc(file=sys.stdout) print("-" * 60)
def test_normal(test): try: print "-----8<----------8<----------8<----------8<----------8<----------8<----- test_normal()" print "First Object:\n" + repr(test) + "\n\n" serialized = pyxser.serialize(obj=test, enc="utf-16", depth=2) print "Serilized Object:\n", serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-16"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-16") unserialized = pyxser.unserialize(obj=serialized, enc="utf-16") print "Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj=test, enc="utf-16", depth=3) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-16"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-16") unserialized = pyxser.unserialize(obj=serialized, enc="utf-16") print "Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj=test, enc="utf-16", depth=4) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-16"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-16") unserialized = pyxser.unserialize(obj=serialized, enc="utf-16") print "Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj=test, enc="utf-16", depth=5) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-16"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-16") unserialized = pyxser.unserialize(obj=serialized, enc="utf-16") print "Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj=test, enc="utf-16", depth=0) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-16"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-16") unserialized = pyxser.unserialize(obj=serialized, enc="utf-16", cinit=False) print "Unserialized Object (d.6):\n" + repr(unserialized) + "\n\n" pyxser.xmlcleanup() except Exception, e: print "-" * 60 print e traceback.print_exc(file=sys.stdout) print "-" * 60
def main(): another = testpkg.sample.TestAnotherObject() another.first_element = 123 another.second_element = 456 other = testpkg.sample.TestAnotherObject() other.first_element = complex(5.82, 3.99) other.second_element = "cdf" thisa = testpkg.sample.TestAnotherObject() thisa.first_element = "xyz" thisa.second_element = complex(7.81, 2.01) thisb = testpkg.sample.TestAnotherObject() thisb.first_element = "456" thisb.second_element = "789" thisc = testpkg.sample.TestAnotherObject() thisc.first_element = "XXX" thisc.second_element = complex(32.1, 33.1) test = testpkg.sample.ParentObject("hola", "chao", 2354345L) test.child("hi", 4.5, 2354) test.nested("holahola", 345, "hola") test.subnested(other) another.dyn_prop1 = thisa test.dyn_prop1 = [u'holá', u'chaó', another] test.dyn_prop2 = (u'hol`', u'sïn', 'trip', other) test.dyn_prop3 = {u'sáludó1': u'hólà', u'sàludà2': u'chäó', u'sáludò4': u'gòódbye', u'saludo5': thisc} test.dyn_prop4 = u'sómé tèxtè ïñ Unicodè' test.dyn_prop5 = u'Añother Texé Iñ ÜnìcóDËc' test.dyn_prop6 = 1.5 test.dyn_prop7 = 1000 try: crawl = 0 while crawl <= 100000: test_normal(test) test_normal_c14n(test) test_unicode(test) test_unicode_c14n(test) test_typemap(test) pyxser.getdtd() pyxser.getdtd_c14n() pyxser.getxsd() pyxser.getxsd_c14n() pyxser.xmlcleanup() if (crawl % 1000) == 0: print "cicle: ", crawl crawl += 1 except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60
def test_selector(test): try: print("-----8<----------8<----------8<----------8<----------8<----------8<----- test_selector()") print("First Object:\n" + repr(test) + "\n\n") x = sel(test) print(repr(x)) serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 2, selector = sel) print("Serilized Object:\n", serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") print("Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 3, selector = sel) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") print("Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 4, selector = sel) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") print("Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 5, selector = sel) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", typemap = {}, cinit = False) print("Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 0, selector = sel) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") print("Unserialized Object (d.0):\n" + repr(unserialized) + "\n\n") pyxser.xmlcleanup() except Exception: print("-" * 60) traceback.print_exc(file=sys.stdout) print("-" * 60)
def test_typemap(test): try: print "-----8<----------8<----------8<----------8<----------8<----------8<----- test_typemap()" print "First Object:\n" + repr(test) + "\n\n" serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 2, typemap = test_typemap_map) print "Serilized Object:\n", serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "ascii"), \ pyxser.validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.unserialize(obj = serialized, enc = "ascii", typemap = test_typemap_map) print "Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 3, typemap = test_typemap_map) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "ascii"), \ pyxser.validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.unserialize(obj = serialized, enc = "ascii", typemap = test_typemap_map) print "Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 4, typemap = test_typemap_map) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "ascii"), \ pyxser.validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.unserialize(obj = serialized, enc = "ascii", typemap = test_typemap_map) print "Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 5, typemap = test_typemap_map) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "ascii"), \ pyxser.validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.unserialize(obj = serialized, enc = "ascii", typemap = test_typemap_map) print "Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 0, typemap = test_typemap_map) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "ascii"), \ pyxser.validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.unserialize(obj = serialized, enc = "ascii", typemap = test_typemap_map, cinit = False) print "Unserialized Object (d.0):\n" + repr(unserialized) + "\n\n" pyxser.xmlcleanup() except Exception, e: print "-" * 60 print e traceback.print_exc(file=sys.stdout) print "-" * 60
def main(): another = testpkg.sample.TestAnotherObject() another.first_element = 123 another.second_element = 456 other = testpkg.sample.TestAnotherObject() other.first_element = complex(5.82, 3.99) other.second_element = "cdf" thisa = testpkg.sample.TestAnotherObject() thisa.first_element = "xyz" thisa.second_element = complex(7.81, 2.01) thisb = testpkg.sample.TestAnotherObject() thisb.first_element = "456" thisb.second_element = "789" thisc = testpkg.sample.TestAnotherObject() thisc.first_element = "XXX" thisc.second_element = complex(32.1, 33.1) test = testpkg.sample.ParentObject("hola", "chao", 2354345L) test.child("hi", 4.5, 2354) test.nested("holahola", 345, "hola") test.subnested(other) another.dyn_prop1 = thisa test.dyn_prop1 = ['hola', 'chao', another] test.dyn_prop2 = ('hola', 'sin', 'trip', other) test.dyn_prop3 = { 'saludo': 'hola', 'saludo2': 'chao', 'saludo3': 'goodbye', 'saludo5': thisc } test.dyn_prop4 = 'some text in unicode' test.dyn_prop5 = 'some text in unicode' test.dyn_prop6 = 1.5 test.dyn_prop7 = 1000 test_normal(test) test_normal_c14n(test) test_unicode(test) test_unicode_c14n(test) test_typemap(test) test_selector(test) print pyxser.getdtd() print pyxser.getdtd_c14n() print pyxser.getxsd() print pyxser.getxsd_c14n() pyxser.xmlcleanup()
def test_unicode(test): try: print "-----8<----------8<----------8<----------8<----------8<----------8<----- test_unicode()" print "First Object:\n" + repr(test) + "\n\n" serialized = pyxser.u_serialize(obj = test, enc = "ascii", depth = 2) print "Serilized Object:\n", serialized.encode("ascii") print "Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "ascii"), \ pyxser.u_validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.u_unserialize(obj = serialized, enc = "ascii") print "Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n" serialized = pyxser.u_serialize(obj = test, enc = "ascii", depth = 3) print "Serilized Object:\n" + serialized.encode("ascii") print "Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "ascii"), \ pyxser.u_validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.u_unserialize(obj = serialized, enc = "ascii") print "Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n" serialized = pyxser.u_serialize(obj = test, enc = "ascii", depth = 4) print "Serilized Object:\n" + serialized.encode("ascii") print "Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "ascii"), \ pyxser.u_validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.u_unserialize(obj = serialized, enc = "ascii") print "Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n" serialized = pyxser.u_serialize(obj = test, enc = "ascii", depth = 5) print "Serilized Object:\n" + serialized.encode("ascii") print "Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "ascii"), \ pyxser.u_validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.u_unserialize(obj = serialized, enc = "ascii") print "Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n" serialized = pyxser.u_serialize(obj = test, enc = "ascii", depth = 0, cinit = False) print "Serilized Object:\n" + serialized.encode("ascii") print "Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "ascii"), \ pyxser.u_validate_dtd(obj = serialized, enc = "ascii") unserialized = pyxser.u_unserialize(obj = serialized, enc = "ascii", typemap = {}, cinit = False) print "Unserialized Object (d.0):\n" + repr(unserialized) + "\n\n" pyxser.xmlcleanup() except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60
def test_normal(test): try: print("-----8<----------8<----------8<----------8<----------8<----------8<----- test_normal()") print("First Object:\n" + repr(test) + "\n\n") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 100) print("Serilized Object:%s\n" % (serialized)) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") print("Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 3) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") print("Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 4) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") print("Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 5) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") print("Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 0) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False) print("Unserialized Object (d.6):\n" + repr(unserialized) + "\n\n") pyxser.xmlcleanup() except Exception: print("-" * 60) traceback.print_exc(file=sys.stdout) print("-" * 60)
def main(): another = testpkg.sample.TestAnotherObject() another.first_element = 123 another.second_element = 456 other = testpkg.sample.TestAnotherObject() other.first_element = complex(5.82, 3.99) other.second_element = "cdf" thisa = testpkg.sample.TestAnotherObject() thisa.first_element = "xyz" thisa.second_element = complex(7.81, 2.01) thisb = testpkg.sample.TestAnotherObject() thisb.first_element = "456" thisb.second_element = "789" thisc = testpkg.sample.TestAnotherObject() thisc.first_element = "XXX" thisc.second_element = complex(32.1, 33.1) test = testpkg.sample.ParentObject("hola", "chao", 2354345) test.child("hi", 4.5, 2354) test.nested("holahola", 345, "hola") test.subnested(other) another.dyn_prop1 = thisa test.dyn_prop1 = ['holá', 'chaó', another] test.dyn_prop2 = ('hol`', 'sïn', 'trip', other) test.dyn_prop3 = { 'sáludó1': 'hólà', 'sáludó2': 'chäó', 'sòludò4': 'goodbye', 'saludo5': thisc } test.dyn_prop4 = 'sómé tèxtè ïñ Unicodè' test.dyn_prop5 = 'Añother Texé Iñ ÜnìcóDËc' test.dyn_prop6 = 1.5 test.dyn_prop7 = 1000 test_normal(test) #test_normal_c14n(test) #test_unicode(test) #test_unicode_c14n(test) #test_typemap(test) #test_selector(test) print(pyxser.getdtd()) print(pyxser.getdtd_c14n()) print(pyxser.getxsd()) print(pyxser.getxsd_c14n()) pyxser.xmlcleanup()
def test_unicode(test): try: print("-----8<----------8<----------8<----------8<----------8<----------8<----- test_unicode()") print("First Object:\n" + repr(test) + "\n\n") serialized = pyxser.u_serialize(obj = test, enc = "utf-8", depth = 2) print("Serilized Object:\n", serialized.encode("latin1")) print("Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "utf-8"), \ pyxser.u_validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8") print("Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n") serialized = pyxser.u_serialize(obj = test, enc = "utf-8", depth = 3) print("Serilized Object:\n" + serialized.encode("latin1")) print("Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "utf-8"), \ pyxser.u_validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8") print("Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n") serialized = pyxser.u_serialize(obj = test, enc = "utf-8", depth = 4) print("Serilized Object:\n" + serialized.encode("latin1")) print("Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "utf-8"), \ pyxser.u_validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8") print("Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n") serialized = pyxser.u_serialize(obj = test, enc = "utf-8", depth = 5) print("Serilized Object:\n" + serialized.encode("latin1")) print("Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "utf-8"), \ pyxser.u_validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8") print("Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n") serialized = pyxser.u_serialize(obj = test, enc = "utf-8", depth = 0) print("Serilized Object:\n" + serialized.encode("latin1")) print("Serilized Object Validation:\n", \ pyxser.u_validate(obj = serialized, enc = "utf-8"), \ pyxser.u_validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8", cinit = False) print("Unserialized Object (d.0):\n" + repr(unserialized) + "\n\n") pyxser.xmlcleanup() except Exception: print("-" * 60) traceback.print_exc(file=sys.stdout) print("-" * 60)
def test_normal(test): try: print "-----8<----------8<----------8<----------8<----------8<----------8<----- test_normal()" print "First Object:\n" + repr(test) + "\n\n" serialized = pyxser.serialize(obj=test, enc="utf-8", depth=2) print "Serilized Object:\n", serialized print "Serilized Object Validation:\n", pyxser.validate(obj=serialized, enc="utf-8"), pyxser.validate_dtd( obj=serialized, enc="utf-8" ) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8") print "Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj=test, enc="utf-8", depth=3) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", pyxser.validate(obj=serialized, enc="utf-8"), pyxser.validate_dtd( obj=serialized, enc="utf-8" ) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8") print "Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj=test, enc="utf-8", depth=4) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", pyxser.validate(obj=serialized, enc="utf-8"), pyxser.validate_dtd( obj=serialized, enc="utf-8" ) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8") print "Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj=test, enc="utf-8", depth=5) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", pyxser.validate(obj=serialized, enc="utf-8"), pyxser.validate_dtd( obj=serialized, enc="utf-8" ) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8") print "Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize(obj=test, enc="utf-8", depth=0) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", pyxser.validate(obj=serialized, enc="utf-8"), pyxser.validate_dtd( obj=serialized, enc="utf-8" ) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8", cinit=False) print "Unserialized Object (d.6):\n" + repr(unserialized) + "\n\n" pyxser.xmlcleanup() except Exception, e: print "-" * 60 print e traceback.print_exc(file=sys.stdout) print "-" * 60
def main(): another = testpkg.sample.TestAnotherObject() another.first_element = 123 another.second_element = 456 other = testpkg.sample.TestAnotherObject() other.first_element = complex(5.82, 3.99) other.second_element = "cdf" thisa = testpkg.sample.TestAnotherObject() thisa.first_element = "xyz" thisa.second_element = complex(7.81, 2.01) thisb = testpkg.sample.TestAnotherObject() thisb.first_element = "456" thisb.second_element = "789" thisc = testpkg.sample.TestAnotherObject() thisc.first_element = "XXX" thisc.second_element = complex(32.1, 33.1) test = testpkg.sample.ParentObject("hola", "chao", 2354345) test.child("hi", 4.5, 2354) test.nested("holahola", 345, "hola") test.subnested(other) another.dyn_prop1 = thisa test.dyn_prop1 = ['holá', 'chaó', another] test.dyn_prop2 = ('hol`', 'sïn', 'trip', other) test.dyn_prop3 = {'sáludó1': 'hólà', 'sáludó2': 'chäó', 'sòludò4': 'goodbye', 'saludo5': thisc} test.dyn_prop4 = 'sómé tèxtè ïñ Unicodè' test.dyn_prop5 = 'Añother Texé Iñ ÜnìcóDËc' test.dyn_prop6 = 1.5 test.dyn_prop7 = 1000 test_normal(test) #test_normal_c14n(test) #test_unicode(test) #test_unicode_c14n(test) #test_typemap(test) #test_selector(test) print(pyxser.getdtd()) print(pyxser.getdtd_c14n()) print(pyxser.getxsd()) print(pyxser.getxsd_c14n()) pyxser.xmlcleanup()
def main(): another = testpkg.sample.TestAnotherObject() another.first_element = 123 another.second_element = 456 other = testpkg.sample.TestAnotherObject() other.first_element = complex(5.82, 3.99) other.second_element = "cdf" thisa = testpkg.sample.TestAnotherObject() thisa.first_element = "xyz" thisa.second_element = complex(7.81, 2.01) thisb = testpkg.sample.TestAnotherObject() thisb.first_element = "456" thisb.second_element = "789" thisc = testpkg.sample.TestAnotherObject() thisc.first_element = "XXX" thisc.second_element = complex(32.1, 33.1) test = testpkg.sample.ParentObject("hola", "chao", 2354345L) test.child("hi", 4.5, 2354) test.nested("holahola", 345, "hola") test.subnested(other) another.dyn_prop1 = thisa test.dyn_prop1 = ['hola', 'chao', another] test.dyn_prop2 = ('hola', 'sin', 'trip', other) test.dyn_prop3 = {'saludo': 'hola', 'saludo2': 'chao', 'saludo3': 'goodbye', 'saludo5': thisc} test.dyn_prop4 = 'some text in unicode' test.dyn_prop5 = 'some text in unicode' test.dyn_prop6 = 1.5 test.dyn_prop7 = 1000 test_normal(test) test_normal_c14n(test) test_unicode(test) test_unicode_c14n(test) test_typemap(test) test_selector(test) print pyxser.getdtd() print pyxser.getdtd_c14n() print pyxser.getxsd() print pyxser.getxsd_c14n() pyxser.xmlcleanup()
def test_typemap(test): try: serialized = pyxser.serialize(obj=test, enc="utf-8", depth=2, typemap=test_typemap_map) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8", typemap=test_typemap_map) serialized = pyxser.serialize(obj=test, enc="utf-8", depth=3, typemap=test_typemap_map) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8", typemap=test_typemap_map) serialized = pyxser.serialize(obj=test, enc="utf-8", depth=4, typemap=test_typemap_map) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8", typemap=test_typemap_map) serialized = pyxser.serialize(obj=test, enc="utf-8", depth=5, typemap=test_typemap_map) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8", typemap=test_typemap_map) serialized = pyxser.serialize(obj=test, enc="utf-8", depth=0, typemap=test_typemap_map) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8", typemap=test_typemap_map) pyxser.xmlcleanup() except Exception, e: print "-" * 60 print e traceback.print_exc(file=sys.stdout) print "-" * 60
def main(): another = testpkg.sample.TestAnotherObject() another.first_element = 123 another.second_element = 456 other = testpkg.sample.TestAnotherObject() other.first_element = complex(5.82, 3.99) other.second_element = "cdf" thisa = testpkg.sample.TestAnotherObject() thisa.first_element = "xyz" thisa.second_element = complex(7.81, 2.01) thisb = testpkg.sample.TestAnotherObject() thisb.first_element = "456" thisb.second_element = "789" thisc = testpkg.sample.TestAnotherObject() thisc.first_element = "XXX" thisc.second_element = complex(32.1, 33.1) test = testpkg.sample.ParentObject("hola", "chao", 2354345L) test.child("hi", 4.5, 2354) test.nested("holahola", 345, "hola") test.subnested(other) another.dyn_prop1 = thisa test.dyn_prop1 = [u"holá", u"chaó", another] test.dyn_prop2 = (u"hol`", u"sïn", "trip", other) test.dyn_prop3 = {u"sáludó1": u"hólà", u"sáludó2": u"chäó", u"sòludò4": u"goodbye", "saludo5": thisc} test.dyn_prop4 = u"sómé tèxtè ïñ Unicodè" test.dyn_prop5 = u"Añother Texé Iñ ÜnìcóDËc" test.dyn_prop6 = 1.5 test.dyn_prop7 = 1000 test_normal(test) test_normal_c14n(test) test_unicode(test) test_unicode_c14n(test) test_typemap(test) test_selector(test) print pyxser.getdtd() print pyxser.getdtd_c14n() print pyxser.getxsd() print pyxser.getxsd_c14n() pyxser.xmlcleanup()
def test_unicode_c14n(test): try: serialized = pyxser.u_serialize_c14n(obj = test, depth = 0, com = 0) pyxser.u_validate_c14n(obj = serialized, enc = "utf-8") pyxser.u_validate_c14n_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8") serialized = pyxser.u_serialize_c14n_strict(obj = test, depth = 0, com = 0) pyxser.u_validate_c14n(obj = serialized, enc = "utf-8") pyxser.xmlcleanup() except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60
def test_unicode_c14n(test): try: serialized = pyxser.u_serialize_c14n(obj=test, depth=0, com=0) pyxser.u_validate_c14n(obj=serialized, enc="utf-8") pyxser.u_validate_c14n_dtd(obj=serialized, enc="utf-8") unserialized = pyxser.u_unserialize(obj=serialized, enc="utf-8") serialized = pyxser.u_serialize_c14n_strict(obj=test, depth=0, com=0) pyxser.u_validate_c14n(obj=serialized, enc="utf-8") pyxser.xmlcleanup() except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60
def test_selector(test): try: x = sel(test) print repr(x) serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 2, selector = sel) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 3, selector = sel) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 4, selector = sel) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 5, selector = sel) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 0, selector = sel) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8") pyxser.xmlcleanup() except Exception, e: print "-" * 60 print e traceback.print_exc(file=sys.stdout) print "-" * 60
def test_selector(test): try: x = sel(test) print repr(x) serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 2, selector = sel) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False) serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 3, selector = sel) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False) serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 4, selector = sel) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False) serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 5, selector = sel) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False) serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 0, selector = sel) pyxser.validate(obj = serialized, enc = "utf-8") pyxser.validate_dtd(obj = serialized, enc = "utf-8") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", cinit = False) pyxser.xmlcleanup() except Exception, e: print "-" * 60 print e traceback.print_exc(file=sys.stdout) print "-" * 60
def test_unicode_c14n(test): try: print("-----8<----------8<----------8<----------8<----------8<----------8<----- test_unicode_c14n()") serialized = pyxser.u_serialize_c14n(obj = test, depth = 0, com = 1) print("Serilized Object:\n" + serialized.encode("latin1")) print("First Object:\n" + repr(test) + "\n\n") print("Serilized Object Validation:\n", \ pyxser.u_validate_c14n(obj = serialized, enc = "utf-8"), \ pyxser.u_validate_c14n_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.u_unserialize(obj = serialized, enc = "utf-8") print("Unserialized Object:\n" + repr(unserialized) + "\n\n") serialized = pyxser.u_serialize_c14n_strict(obj = test, depth = 0, com = 0) print("Serilized Object:\n" + serialized.encode("latin1")) print("Serilized Object Validation:\n", pyxser.u_validate_c14n(obj = serialized, enc = "utf-8")) print("First Object:\n" + repr(test) + "\n\n") pyxser.xmlcleanup() except Exception: print("-" * 60) traceback.print_exc(file=sys.stdout) print("-" * 60)
def test_normal_c14n(test): try: print "-----8<----------8<----------8<----------8<----------8<----------8<----- test_normal_c14n()" print "First Object:\n" + repr(test) + "\n\n" serialized = pyxser.serialize_c14n(obj = test, depth = 0, com = 0) print "Serilized Object:\n" + serialized print "First Object:\n" + repr(test) + "\n\n" print "Serilized Object Validation:\n", \ pyxser.validate_c14n(obj = serialized, enc = "utf-16"), \ pyxser.validate_c14n_dtd(obj = serialized, enc = "utf-16") unserialized = pyxser.unserialize(obj = serialized, enc = "utf-16") print "Unserialized Object:\n" + repr(unserialized) + "\n\n" serialized = pyxser.serialize_c14n_strict(obj = test, depth = 0, com = 0) print "Serilized Object:\n" + serialized print "Serilized Object Validation:\n", pyxser.validate_c14n(obj = serialized, enc = "utf-16") print "First Object:\n" + repr(test) + "\n\n" pyxser.xmlcleanup() except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60
def test_typemap(test): try: serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 2, typemap = test_typemap_map) unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", typemap = test_typemap_map) serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 3, typemap = test_typemap_map) unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", typemap = test_typemap_map) serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 4, typemap = test_typemap_map) unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", typemap = test_typemap_map) serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 5, typemap = test_typemap_map) unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", typemap = test_typemap_map) serialized = pyxser.serialize(obj = test, enc = "utf-8", depth = 0, typemap = test_typemap_map) unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8", typemap = test_typemap_map) pyxser.xmlcleanup() except Exception, e: print "-" * 60 print e traceback.print_exc(file=sys.stdout) print "-" * 60
def test_selector(test): try: print( "-----8<----------8<----------8<----------8<----------8<----------8<----- test_selector()" ) print("First Object:\n" + repr(test) + "\n\n") x = sel(test) print(repr(x)) serialized = pyxser.serialize(obj=test, enc="utf-8", depth=2, selector=sel) print("Serilized Object:\n", serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8") print("Unserialized Object (d.2):\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize(obj=test, enc="utf-8", depth=3, selector=sel) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8") print("Unserialized Object (d.3):\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize(obj=test, enc="utf-8", depth=4, selector=sel) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8") print("Unserialized Object (d.4):\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize(obj=test, enc="utf-8", depth=5, selector=sel) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8", typemap={}, cinit=False) print("Unserialized Object (d.5):\n" + repr(unserialized) + "\n\n") serialized = pyxser.serialize(obj=test, enc="utf-8", depth=0, selector=sel) print("Serilized Object:\n" + serialized) print("Serilized Object Validation:\n", \ pyxser.validate(obj = serialized, enc = "utf-8"), \ pyxser.validate_dtd(obj = serialized, enc = "utf-8")) unserialized = pyxser.unserialize(obj=serialized, enc="utf-8") print("Unserialized Object (d.0):\n" + repr(unserialized) + "\n\n") pyxser.xmlcleanup() except Exception: print("-" * 60) traceback.print_exc(file=sys.stdout) print("-" * 60)
print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60 try: print "-" * 60 serialized = pyxser.serialize(obj=test, enc="ascii", depth=2) print serialized print "-" * 60 unserialized = pyxser.unserialize(obj=serialized, enc="ascii") print unserialized except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60 try: serialized = pyxser.serialize(obj=test, enc="latin-1", depth=2) unserialized = pyxser.unserialize(obj=serialized, enc="latin-1") except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60 try: pyxser.xmlcleanup() except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60
traceback.print_exc(file=sys.stdout) print "-" * 60 try: print "-" * 60 serialized = pyxser.serialize(obj = test, enc = "ascii", depth = 2) print serialized print "-" * 60 unserialized = pyxser.unserialize(obj = serialized, enc = "ascii") print unserialized except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60 try: serialized = pyxser.serialize(obj = test, enc = "latin-1", depth = 2) unserialized = pyxser.unserialize(obj = serialized, enc = "latin-1") except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60 try: pyxser.xmlcleanup(); except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60
test.child("hi", 4.5, 2354) test.nested("holahola", 345, "hola") test.subnested(other) another.dyn_prop1 = thisa test.dyn_prop1 = [u'holá', u'chaó', another] test.dyn_prop2 = (u'hol`', u'sïn', 'trip', other) test.dyn_prop3 = {'saludo1': u'hólà', 'saludo2': u'chäó', 'saludo4': 'goodbye', 'saludo5': thisc} test.dyn_prop4 = u'sómé tèxtè ïñ Unicodè' test.dyn_prop5 = u'Añother Texé Iñ ÜnìcóDËc' test.dyn_prop6 = 1.5 test.dyn_prop7 = 1000 try: crawl = 0 while crawl < 1000: test_all(test) if (crawl % 1000) == 0: print "cicle: ", crawl crawl += 1 except Exception, e: print "-" * 60 traceback.print_exc(file=sys.stdout) print "-" * 60 pyxser.xmlcleanup() hps = h.heapu() display_heap(hps)