mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-13 10:46:29 +03:00
Move read_json out to own util function
This commit is contained in:
parent
d7229967b0
commit
31fa73293a
|
@ -113,12 +113,15 @@ def check_renamed_kwargs(renamed, kwargs):
|
||||||
raise TypeError("Keyword argument %s now renamed to %s" % (old, new))
|
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):
|
def parse_package_meta(package_path, package, require=True):
|
||||||
location = package_path / package / 'meta.json'
|
location = package_path / package / 'meta.json'
|
||||||
if location.is_file():
|
if location.is_file():
|
||||||
with location.open('r', encoding='utf8') as f:
|
return read_json(location)
|
||||||
meta = ujson.load(f)
|
|
||||||
return meta
|
|
||||||
elif require:
|
elif require:
|
||||||
raise IOError("Could not read meta.json from %s" % location)
|
raise IOError("Could not read meta.json from %s" % location)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user