B An]W@sddlmZmZddlZddlmZddlZddlZddlZddl m Z ddl m Z ddl mZddlmZd d Zd d Zd dZdddZddZddZddZdS))unicode_literalsprint_functionN)Path)Printer)path2str) get_data_path)aboutc st}|d4ttj}|jdkr@|jd|jdddWdQRX| d| d }tj }| d dd }||s|jd |tjddt }xRt|D]B\}}||x*|D]\}}d d|D|||<qWqWt} t|} dd| D} dd| D} | dd| Dfdd| D} fdd| D}ttjj}|dtj |dt|| s| rd}g}x*| D]\}}|t|||qWx,| D] \}}|t|||dqW|j||dn|jdd d|rd|d|ddtdfdd|Dd| r|d tj d!| | r|d"jtt d#| s| rt!"ddS)$z Validate that the currently installed version of spaCy is compatible with the installed models. Should be run after `pip install -U spacy`. zLoading compatibility table...zServer error ({})z#Couldn't fetch compatibility table.)exitsNzLoaded compatibility tablespacyz.devrz+Can't find spaCy v{} in compatibility tablecSsg|] }t|qS)reformat_version).0vrru/home/app_decipher_dev_19-4/dev/decipher-analysis/serverless-application/helper/df_spacy/python/spacy/cli/validate.py -szvalidate..cSsh|]\}}|ds|qS)compatr)rldrrr 0szvalidate..cSs h|]\}}|ds|dqS)rnamer)r_rrrrr1scSs g|]\}}|ds|dqS)rrr)rrrrrrr3scsg|]}|kr|qSrr)rm)current_compatrrr5scsg|]}|kr|qSrr)rr)rrrr6szInstalled models (spaCy v{})zspaCy installation: {})ZTYPENAMEZMODELVERSIONlink)headerz,No models found in your current environment.zInstall updatesz8Use the following commands to update the model packages:zpython -m spacy download {} csg|]}|qSr)format)rpkg)cmdrrrJsz8The following models are not available for spaCy v{}: {}z, zYou may also want to overwrite the incompatible links using the `python -m spacy link` command with `--force`, or remove them from the data directory. Data path: {path})path)#rloadingrequestsgetr __compatibility__ status_codefailr"goodjson __version__rsplitsetdictitemsupdatekeysget_model_linksget_model_pkgsr__file__parentdividerinforappend get_model_rowtabletextprintjoinrsysexit)msgrrversion all_modelsZspacy_vmodelsmodelZmodel_vsZ model_linksZ model_pkgsZincompat_linksZincompat_modelsZ na_modelsZ update_modelsZ spacy_dirr rowsrdatar)r$rrvalidatest              rKc Csi}t}|rdd|D}xj|D]b}t|d}|s@q&t|}|jd}|dd|d}||dt|||dd ||<q&W|S) NcSsg|]}t|r|qSr) is_model_path)rprrrr_sz#get_model_links..z meta.jsonlangrrrE)rrEr)riterdirrexistssrsly read_jsonparts is_compat) rlinks data_pathrGrH meta_pathmetarrrrrr5[s    r5cCsTi}xJtjjD]:\}}|dd}||kr|j}||t|||d||<qW|S)N-r)rrEr) pkg_resources working_setby_keyr2replacerErU)rrFZpkgspkg_nameZpkg_datapackagerErrrr6os r6r`cCsr|dr0|jddddd}|j|dddd}n0|j|dd dd}d ||d d gd }|||d ||fS)Nrrgreenr,T)coloriconno_printrE)rbrdredz--> {}rzn/ar)r>r"r()rrrJrCZ model_typecomprErrrr<}s r<cCs0dddg}|jd}|o.||ko.|d S)Ncachepycache __pycache__rN.)rTis_dir startswith) model_pathexcluderrrrrLs  rLcCs||ko|||kS)Nr)rrrErrrrUsrUcCs"|dr|ddS|ddS)zEHack to reformat old versions ending on '-alpha' to match pip format.z-alphaa0a)endswithr^)rErrrrs  r)r`) __future__rrr[pathlibrrAr'rRwasabirrrutilrrr rKr5r6r<rLrUrrrrrs      K