U á€C^q ã@s~ddlmZddlZddlmZddlmZddlmZm Z ddl m Z ej dd de fd d de fd d d efdddd„ƒZdS)é)Úunicode_literalsN)ÚPath)Úmsgé)Ú symlink_toÚpath2str)Úutilz#package name or local path to modelÚ positionalzname of shortuct link to createz"force overwriting of existing linkÚflagÚf)ÚoriginÚ link_nameÚforceFcCsVt |¡rt |¡}n|dkr&t|ƒnt|ƒ}| ¡sPtjdd t|ƒ¡ddt  ¡}|rd| ¡sˆtt ƒj j }tjddj|dddt  ¡|}|  ¡r¸|s¸tjd  |¡d ddn0|  ¡rÊ|  ¡n| ¡rètjd  |¡d ddd t|ƒt|ƒf}zt||ƒWn*t d |¡d¡t |¡‚YnXt d|¡t d |¡¡dS)zå Create a symlink for models within the spacy/data directory. Accepts either the name of a pip package, or the local path to the model data directory. Linking models allows loading them via spacy.load(link_name). NzCan't locate model dataz The data should be located in {}é)Zexitsz6Can't find the spaCy data path to create model symlinkz}Make sure a directory `/data` exists within your spaCy installation and try again. The data directory should be located here:)ÚpathzLink '{}' already existsz3To overwrite an existing link, use the --force flagzCan't overwrite symlink '{}'zUThis can happen if your data directory contains a directory or file of the same name.z %s --> %szCouldn't link model to '{}'zùCreating a symlink in spacy/data failed. Make sure you have the required permissions and try re-running the command as admin, or use a virtualenv. You can still import the model as a module and call its load() method, or create the symlink manually.zLinking successfulz/You can now load the model via spacy.load('{}'))rÚ is_packageZget_package_pathrÚexistsrÚfailÚformatrZ get_data_pathÚ__file__ÚparentÚ is_symlinkÚunlinkrÚtextZgood)r r rZ model_pathZ data_pathZ spacy_locÚ link_pathÚdetails©rú1/tmp/pip-install-6_kvzl1k/spacy/spacy/cli/link.pyÚlink s\   ý  þû  ý üþ  r)FN)Ú __future__rZplacÚpathlibrZwasabirÚcompatrrÚrÚ annotationsÚstrÚboolrrrrrÚs       ý