convert.py 590 B

1234567891011121314151617181920
  1. import core.export.utils.py2xml
  2. import core.export.utils.py2txt
  3. def to_xml(data, root_name = None):
  4. serializer = core.export.utils.py2xml.Py2XML()
  5. return serializer.parse(data, objName=root_name)
  6. def to_python(data, root_name = None):
  7. prefix = ""
  8. postfix = ""
  9. if root_name != None:
  10. prefix = "{'" + root_name + ": "
  11. postfix = "}"
  12. return prefix + data.__repr__() + postfix
  13. def to_txt(data, root_name = None):
  14. serializer = core.export.utils.py2txt.Py2TXT()
  15. return serializer.parse(data, objName=root_name, indent = -1)