mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 01:16:28 +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))
|
||||
|
||||
|
||||
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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user