Move read_json out to own util function

This commit is contained in:
ines 2017-04-16 13:03:28 +02:00
parent d7229967b0
commit 31fa73293a

View File

@ -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: