From dd3244c08ab6a7816698fdedd9297cef9eac3629 Mon Sep 17 00:00:00 2001 From: Gyorgy Orosz Date: Thu, 13 Apr 2017 23:30:47 +0200 Subject: [PATCH] Made json dump to produce unicode strings in py2 --- spacy/cli/package.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spacy/cli/package.py b/spacy/cli/package.py index 6de2fd140..e88f91bf4 100644 --- a/spacy/cli/package.py +++ b/spacy/cli/package.py @@ -6,9 +6,15 @@ import shutil import requests from pathlib import Path +import six + from .. import about 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): input_path = Path(input_dir) @@ -27,7 +33,7 @@ def package(input_dir, output_dir, force): create_dirs(package_path, force) 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 / 'MANIFEST.in', template_manifest) create_file(package_path / '__init__.py', template_init)