mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-24 00:46:28 +03:00
Let parse_package_meta take full path
This commit is contained in:
parent
326746eb15
commit
95edd9e896
|
@ -12,7 +12,7 @@ from .. import util
|
|||
def info(model=None, markdown=False):
|
||||
if model:
|
||||
data_path = util.get_data_path()
|
||||
data = util.parse_package_meta(data_path, model, require=True)
|
||||
data = util.parse_package_meta(data_path / model, require=True)
|
||||
model_path = Path(__file__).parent / data_path / model
|
||||
if model_path.resolve() != model_path:
|
||||
data['link'] = path2str(model_path)
|
||||
|
|
|
@ -142,20 +142,17 @@ def get_model_package_path(package_name):
|
|||
# Python's installation and import rules are very complicated.
|
||||
pkg = importlib.import_module(package_name)
|
||||
package_path = Path(pkg.__file__).parent.parent
|
||||
meta = parse_package_meta(package_path, package_name)
|
||||
meta = parse_package_meta(package_path / package_name)
|
||||
model_name = '%s-%s' % (package_name, meta['version'])
|
||||
return package_path / package_name / model_name
|
||||
|
||||
|
||||
def parse_package_meta(package_path, package, require=True):
|
||||
def parse_package_meta(package_path, require=True):
|
||||
"""
|
||||
Check if a meta.json exists in a package and return its contents as a
|
||||
dictionary. If require is set to True, raise an error if no meta.json found.
|
||||
"""
|
||||
# TODO: Allow passing in full model path and only require one argument
|
||||
# instead of path and package name. This lets us avoid passing in an awkward
|
||||
# empty string in spacy.load() if user supplies full model path.
|
||||
location = package_path / package / 'meta.json'
|
||||
location = package_path / 'meta.json'
|
||||
if location.is_file():
|
||||
return read_json(location)
|
||||
elif require:
|
||||
|
|
Loading…
Reference in New Issue
Block a user