B An]/@sddlmZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl m Z eZejd d defd d d efdddddZddZddZddZdddZdS))unicode_literalsN)Printer)link)get_package_path)aboutz$Model to download (shortcut or name) positionalz'Force direct download of name + versionflagdzCadditional arguments to be passed to `pip install` on model install)modeldirectpip_argsFc Gsd}|rB|d}d|dd}|d}t|j||d|}nttjd}|||}t} t || }t|j||d|}|dkrt |t d d |||kryt|} t||d | d Wn t d d||YnXdS)z Download compatible model from default download path using pip. Model can be shortcut, model name or, if --direct flag is set, full model name with version. For direct downloads, the compatibility check will be skipped. z#{m}-{v}/{m}-{v}.tar.gz#egg={m}=={v}-N)mvzavailable shortcutsrz$Download and installation successfulz/You can now load the model via spacy.load('{}')T)forceZ model_pathz&Download successful but linking failedzCreating a shortcut link for '{}' didn't work (maybe you don't have admin permissions?), but you can still load the model via its full package name: nlp = spacy.load('{}'))splitjoindownload_modelformatget_jsonrZ __shortcuts__getget_compatibility get_versionsysexitmsggoodrrwarn) r r rZdl_tpl componentsZ model_nameversionZdlZ shortcutsZ compatibility package_pathr%u/home/app_decipher_dev_19-4/dev/decipher-analysis/serverless-application/helper/df_spacy/python/spacy/cli/download.pydownloads2       r'cCs>t|}|jdkr6tjd|jd|tjdd|S)NzServer error ({})zCouldn't fetch {}. Please find a model for your spaCy installation (v{}), and download it manually. For more details, see the documentation: https://spacy.io/usage/modelsr)exits) requestsrZ status_coderfailrr __version__json)urldescrr%r%r&rHs   rcCsNtj}|ddd}ttjd}|d}||krFtjd|dd||S)Nz.devrrzcompatibility tableZspacyz+No compatible models found for v{} of spaCy)r))rr,rsplitrZ__compatibility__rr+r)r#Z comp_tablecompr%r%r&rVs rcCs<|ddd}||kr0tjd|tjdd||dS)Nz.devrrz/No compatible model found for '{}' (spaCy v{}).)r))r1rr+rrr,)r r2r%r%r&r`srcCsPtjd|}ddg}|r$||tjdddg||g}tj|tj dS)N/z--no-cache-dirz --no-depsz-mZpipinstall)env) rZ__download_url__extendr executable subprocesscallosenvironcopy)filenameZ user_pip_argsZ download_urlrcmdr%r%r&rks  r)F)N) __future__rZplacr*r:r8rwasabirrutilrrrr annotationsstrboolr'rrrrr%r%r%r&s&        0