From 3d484c3faf43a7957047ee419a588fac3d4d0e3e Mon Sep 17 00:00:00 2001 From: ines Date: Thu, 16 Mar 2017 20:34:50 +0100 Subject: [PATCH] Don't print in parse_package_meta and accept on_erro callback instead TODO: log warning for missing meta data in spacy.link, as this affects the Language class returned by spacy.load() --- spacy/util.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spacy/util.py b/spacy/util.py index 946ce6aab..ef6d9884d 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -149,11 +149,10 @@ def check_renamed_kwargs(renamed, kwargs): raise TypeError("Keyword argument %s now renamed to %s" % (old, new)) -def parse_package_meta(package_path, package): +def parse_package_meta(package_path, package, on_error=False): 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") + if not os.path.isfile(location) and on_error: + on_error() else: with io.open(location, encoding='utf8') as f: meta = json.load(f)