예제 #1
0
 def test_round_trip(self):
     pytools.create_template("utf8_test.py", "junk.template")
     pytools.py2json("utf8_test.py", "junk.json")
     pytools.json2py("junk.json", "junk.template", "junk.py")
     self.assertTrue(filecmp.cmp("utf8_test.py", "junk.py", shallow=False))
     for f in ["junk.template", "junk.json", "junk.py"]:
         os.remove(f)
예제 #2
0
'''Might as well use easygui_qt since I created it ...'''

import easygui_qt as ez
import pytools

METHODS = {
    "create_template": pytools.create_template,
    "py2json": pytools.py2json,
    "json2py": pytools.json2py
}

method = ez.get_choice("What method?", choices=list(METHODS.keys()))
infile = ez.get_file_names("Input file (method = %s)" % method)[0]
outfile = ez.get_save_file_name("Output file (method = %s)" % method)

if method == "json2py":
    template = ez.get_file_names("Get template")[0]
    pytools.json2py(infile, template, outfile)
else:
    METHODS[method](infile, outfile)