Add meta validation to check for required settings

Complain if no "lang", "name" or "version" is found (those settings are
used in directory / package names). Package will still build without,
but it'll inevitably fail somewhere down the line.
This commit is contained in:
ines 2017-04-16 13:13:17 +02:00
parent a7574b7572
commit e3de035814

View File

@ -26,6 +26,7 @@ def package(input_dir, output_dir, meta_path, force):
else:
meta = generate_meta()
validate_meta(meta, ['lang', 'name', 'version'])
model_name = meta['lang'] + '_' + meta['name']
model_name_v = model_name + '-' + meta['version']
main_path = output_path / model_name_v
@ -89,6 +90,14 @@ def generate_meta():
return meta
def validate_meta(meta, keys):
for key in keys:
if key not in meta or meta[key] == '':
util.sys_exit(
"This setting is required to build your package.",
title='No "{k}" setting found in meta.json'.format(k=key))
def get_template(filepath):
url = 'https://raw.githubusercontent.com/explosion/spacy-dev-resources/master/templates/model/'
r = requests.get(url + filepath)