Пример #1
0
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
Пример #2
0
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
Пример #3
0
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)
Пример #4
0
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
Пример #5
0
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
Пример #6
0
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
Пример #7
0
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)
Пример #8
0
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
Пример #9
0
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
Пример #10
0
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)
Пример #11
0
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
Пример #12
0
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
Пример #13
0
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 = "ascii"), \
              pyxser.validate_c14n_dtd(obj = serialized, enc = "ascii")
        unserialized = pyxser.unserialize(obj=serialized, enc="ascii")
        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="ascii")
        print "First Object:\n" + repr(test) + "\n\n"

        pyxser.xmlcleanup()

    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60
Пример #14
0
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
Пример #15
0
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
Пример #16
0
def xml_process(message):
    ''' Decode a message from the xml format

    :param message: The message to pre-process
    :return: The pre-processed message
    '''
    try:
        message = pyxser.unserialize(obj=message, enc="utf-8")
    except: message = _default_message()
    return message
Пример #17
0
def main():
    engine = sqlalchemy.create_engine('sqlite:///:memory:', echo=True)
    metadata = sqlalchemy.MetaData()
    metadata.create_all(engine)
    session = sqlalchemy.orm.sessionmaker(bind=engine)
    ed_user = s.User()
    ed_user.fullname = 'Ed Jones'
    ed_user.password = '******'
    ed_user.name = 'ed'
    serialized = pyxser.serialize(obj = ed_user, enc = 'iso-8859-1', depth = 100)
    print serialized
    ed_unser = pyxser.unserialize(obj = serialized, enc = "iso-8859-1")
    print repr(ed_unser)
    print repr(ed_unser.get_set())
Пример #18
0
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
Пример #19
0
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
Пример #20
0
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
Пример #21
0
def main():
    xml_str = '<?xml version="1.0" encoding="utf-8"?>' \
              + '<pyxs:obj xmlns:pyxs="http://projects.coder.cl/pyxser/model/" ' \
              + 'version="1.0" type="ContainerClass" module="__main__" '\
              + 'objid="id5642896">' \
              + '<pyxs:prop type="bool" name="dummy">True</pyxs:prop>' \
              + '<pyxs:col type="list" name="embedded">' \
              + '<pyxs:obj type="object" module="__builtin__" ' \
              + 'objid="id1488096"/>' \
              + '<pyxs:obj type="object" module="__builtin__" ' \
              + 'objid="id1488056"/>' \
              + '</pyxs:col></pyxs:obj>'
    unser = pyxser.unserialize(obj = xml_str, enc='utf-8')
    print repr(unser)
    print repr(unser.__dict__)
Пример #22
0
def test_normal_c14n(test):
    try:
        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")
        unserialized = pyxser.unserialize(obj = serialized, enc = "utf-8")

        serialized = pyxser.serialize_c14n_strict(obj = test, depth = 0, com = 0)
        pyxser.validate_c14n(obj = serialized, enc = "utf-8")

        pyxser.xmlcleanup()

    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60
Пример #23
0
def test_normal_c14n(test):
    try:
        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")
        unserialized = pyxser.unserialize(obj=serialized, enc="utf-8")

        serialized = pyxser.serialize_c14n_strict(obj=test, depth=0, com=0)
        pyxser.validate_c14n(obj=serialized, enc="utf-8")

        pyxser.xmlcleanup()

    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60
Пример #24
0
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)
Пример #25
0
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)
Пример #26
0
    try:
        serialized = pyxser.serialize(obj=None, enc=None, depth="hola")
    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60

    try:
        pyxser.validate("wawawawaw", enc="utf-8")
    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60

    try:
        unserialized = pyxser.unserialize(obj="wawawawaw", enc="utf-8")
    except Exception, e:
        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)
Пример #27
0
    try:
        serialized = pyxser.serialize(obj = None, enc = None, depth = "hola")
    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60

    try:
        pyxser.validate("wawawawaw", enc = "utf-8")
    except Exception, e:
        print "-" * 60
        traceback.print_exc(file=sys.stdout)
        print "-" * 60

    try:
        unserialized = pyxser.unserialize(obj = "wawawawaw", enc = "utf-8")
    except Exception, e:
        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)