Made json dump to produce unicode strings in py2

This commit is contained in:
Gyorgy Orosz 2017-04-13 23:30:47 +02:00
parent 0c73af6943
commit dd3244c08a

View File

@ -6,9 +6,15 @@ import shutil
import requests import requests
from pathlib import Path from pathlib import Path
import six
from .. import about from .. import about
from .. import util from .. import util
if six.PY2:
json_dumps = lambda data: json.dumps(data, indent=2).decode("utf8")
elif six.PY3:
json_dumps = lambda data: json.dumps(data, indent=2)
def package(input_dir, output_dir, force): def package(input_dir, output_dir, force):
input_path = Path(input_dir) input_path = Path(input_dir)
@ -27,7 +33,7 @@ def package(input_dir, output_dir, force):
create_dirs(package_path, force) create_dirs(package_path, force)
shutil.copytree(input_path.as_posix(), (package_path / model_name_v).as_posix()) shutil.copytree(input_path.as_posix(), (package_path / model_name_v).as_posix())
create_file(main_path / 'meta.json', json.dumps(meta, indent=2)) create_file(main_path / 'meta.json', json_dumps(meta))
create_file(main_path / 'setup.py', template_setup) create_file(main_path / 'setup.py', template_setup)
create_file(main_path / 'MANIFEST.in', template_manifest) create_file(main_path / 'MANIFEST.in', template_manifest)
create_file(package_path / '__init__.py', template_init) create_file(package_path / '__init__.py', template_init)