
    i$                     B   d dl Z d dlZd dlmZ d dlmZmZmZmZm	Z	 d dl
Z
d dlmZmZ ddlmZmZ ddlmZ dd	lmZmZmZmZ dd
lmZmZ  ej6                  d       edd       edddd       eddddd       edddd       edddd      fdee   deded ed!ef
d"       Z	 d/dd#ddd$dee   deded eee      d!ed%e	eef   fd&Z d%eeef   fd'Z!d#d(deded%eeef   fd)Z"ded%ee   fd*Z#ded%eeef   fd+Z$	 	 d0d,eeef   d-ee   d eee      d%efd.Z%y)1    N)Path)AnyDictListOptionalUnion)MarkdownRendererPrinter   )aboututil)importlib_metadata   )ArgOptappstring_to_list)get_latest_versionget_model_filenameinfoz Optional loadable spaCy pipeline)helpFz
--markdownz-mdz#Generate Markdown for GitHub issuesz--silentz-sz-Sz"Don't print anything (just return)labelsz	--excludez-ez2Comma-separated keys to exclude from the print-outz--urlz-uzLPrint the URL to download the most recent compatible version of the pipelinemodelmarkdownsilentexcludeurlc                 :    t        |      }t        | ||||       y)aa  
    Print info about spaCy installation. If a pipeline is specified as an argument,
    print its meta information. Flag --markdown prints details in Markdown for easy
    copy-pasting to GitHub issues.

    Flag --url prints only the download URL of the most recent compatible
    version of the pipeline.

    DOCS: https://spacy.io/api/cli#info
    r   r   r   r   N)r   r   )r   r   r   r   r   s        _/var/www/vps2.regionflexible.com/Desarrollo/venv/lib/python3.12/site-packages/spacy/cli/info.pyinfo_clir!      s&    D W%G    Tr   returnc                   t        ||       }|sg }|r7| !d|  d}t        |       }t        |d          |S |j                  dd       n"| rd|  d}t	        | |	      }nd
}t               }j                         D 	ci c]&  \  }}	|j                         j                  dd      |	( }
}}	d|v r?t        |d   t              r,dj                  d |d   j                         D              |d<   t        ||      }|r|st        |       |S |s;|j                         D 	ci c]  \  }}	||vs||	 }}}	|j                  ||       |
S c c}	}w c c}	}w )Nno_printprettyzDownload info for pipeline ''download_urlz%--url option requires a pipeline namer   exitszInfo about pipeline 'r   zInfo about spaCy _	Pipelinesz, c              3   2   K   | ]  \  }}| d | d  yw)z ()N ).0nvs      r    	<genexpr>zinfo.<locals>.<genexpr>V   s%      &
!QqcA3aL&
s   )titler   )r7   )r
   info_model_urlprintfail
info_model
info_spacyitemslowerreplace
isinstancedictjoinget_markdowntable)r   r   r   r   r   msgr7   datakr5   raw_datamarkdown_data
table_datas                r    r   r   ;   sp    6f*
5C
25';E!%(D$~&'KHH<AHF	'wa0%/"|;?::<H41a	!!#s+Q.HHHdz${*;TB II &
%)+%6%<%<%>&
 
[ !UGDM- '+zz|Htq!q7GadH
H		*E	*O I Is   +E&E3Ec                  T   i } t        j                         D ],  }|j                  dd      }t        j                  |      | |<   . t        j
                  t        t        t              j                  j                        t        j                         t        j                         | dS )z\Generate info about the current spaCy intallation.

    RETURNS (dict): The spaCy info.
    -r.   )zspaCy versionLocationPlatformzPython versionr/   )r   get_installed_modelsr?   get_package_versionr   __version__strr   __file__parentplatformpython_version)
all_modelspkg_namepackages      r    r<   r<   d   s    
 J--/ A""3,"66x@
7A **X--445%%'"113 r"   r,   c                   t        ||       }t        j                  |       rt        j                  |       }nt	        |       }|dz  }|j                         s|j                  d|d       t        j                  |      }|j                         |k7  rt        |j                               |d<   nt        |      |d<   t        |       }|r||d<   |j                         D ci c]  \  }}|dvs|| c}}S c c}}w )	zGenerate info about a specific model.

    model (str): Model name of path.
    silent (bool): Don't print anything, just return.
    RETURNS (dict): The model meta.
    r%   z	meta.jsonzCan't find pipeline meta.jsonr   r*   sourcer)   )accuracyperformancespeed)r
   r   
is_packageget_package_pathr   is_filer:   srsly	read_jsonresolverR   info_installed_model_urlr=   )	r   r   rE   
model_path	meta_pathmetar)   rG   r5   s	            r    r;   r;   v   s     6f*
5Cu**51
%[
[(I0)1E??9%Dz)Z//12XZX+E2L+^A2V)V1  s   &C<3C<c                     	 t        j                  |       }|j                  d      }t        |t              rt        j                  |      }|d   S 	 y# t        $ r Y yw xY w)zGiven a pipeline name, get the download URL if available, otherwise
    return None.

    This is only available for pipelines installed as modules that have
    dist-info available.
    zdirect_url.jsonr   N)r   distribution	read_textr@   rR   jsonloads	Exception)r   disttextrF   s       r    re   re      si    !..u5~~/0dC ::d#D; !
   s   AA 	A A c                     t        |       }t        | |      }t        j                  dz   |z   }d}|j	                  | |      }||dS )z=Return the download URL for the latest version of a pipeline./z>https://github.com/explosion/spacy-models/releases/tag/{m}-{v})mr5   )r)   release_url)r   r   r   __download_url__format)r   versionfilenamer)   release_tplrt   s         r    r8   r8      sR     'G!%1H))C/(:LRK$$u$8K(EEr"   rF   r7   c                    t               }|r!|j                  |j                  d|             g }| j                         D ]a  \  }}|r||v rt	        |t
              r	 t        |      j                         }|r:|j                  |j                  | d       d|        c |j                  |j                  |             d|j                   dS # t        $ r d}Y jw xY w)a  Get data in GitHub-flavoured Markdown format for issues etc.

    data (Dict[str, Any]): Label/value pairs.
    title (str): Optional title, will be rendered as headline 2.
    exclude (List[str]): Names of keys to exclude.
    RETURNS (str): The Markdown string.
    r   F:r-   
)r	   addr7   r=   r@   rR   r   existsrn   appendboldlistrp   )rF   r7   r   mdr=   keyvalueexisting_paths           r    rC   rC      s     
	B
rxx5!"Ejjl 6
Usg~eS!& $U 2 2 4 3%q	*+1UG456 FF2775>y  & %&s   CC"!C")N)NN)&rl   rU   pathlibr   typingr   r   r   r   r   rb   wasabir	   r
    r   r   compatr   _utilr   r   r   r   downloadr   r   commandrR   boolr!   rA   r   r<   r;   re   r8   rC   r2   r"   r    <module>r      s      3 3  ,  ' 0 0 < V t*LM|U)N z4,P A	 [	(C=( ( ( ( 
( (X  & #'&C=& & 	&
 d3i & 
& 39&RDcN $ .2 c d d38n 8C HSM $F# F$sCx. F  #'
sCx.C= d3i  		r"   