From 31fa73293a260a764fda000f72a167a56eab6330 Mon Sep 17 00:00:00 2001 From: ines Date: Sun, 16 Apr 2017 13:03:28 +0200 Subject: [PATCH] Move read_json out to own util function --- spacy/util.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spacy/util.py b/spacy/util.py index 219009f17..5fd9d563b 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -113,12 +113,15 @@ def check_renamed_kwargs(renamed, kwargs): raise TypeError("Keyword argument %s now renamed to %s" % (old, new)) +def read_json(location): + with location.open('r', encoding='utf8') as f: + return ujson.load(f) + + def parse_package_meta(package_path, package, require=True): location = package_path / package / 'meta.json' if location.is_file(): - with location.open('r', encoding='utf8') as f: - meta = ujson.load(f) - return meta + return read_json(location) elif require: raise IOError("Could not read meta.json from %s" % location) else: