mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-11 00:32:40 +03:00
Add util function to load and parse package meta.json
This commit is contained in:
parent
7f920c2f75
commit
5f3f04bd0a
|
@ -149,6 +149,18 @@ 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 parse_package_meta(package_path, package):
|
||||||
|
location = os.path.join(str(package_path), package, 'meta.json')
|
||||||
|
if not os.path.isfile(location):
|
||||||
|
print_msg("'{p}' doesn't seem to be a valid model package.".format(p=package),
|
||||||
|
title="No meta.json found")
|
||||||
|
else:
|
||||||
|
with io.open(location, encoding='utf8') as f:
|
||||||
|
meta = json.load(f)
|
||||||
|
return meta
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def print_msg(*text, **kwargs):
|
def print_msg(*text, **kwargs):
|
||||||
"""Print formatted message. Each positional argument is rendered as newline-
|
"""Print formatted message. Each positional argument is rendered as newline-
|
||||||
separated paragraph. If kwarg 'title' exist, title is printed above the text
|
separated paragraph. If kwarg 'title' exist, title is printed above the text
|
||||||
|
|
Loading…
Reference in New Issue
Block a user