3
®ybÉ  ã               @   sê   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlmZm	Z	m
Z
 d dlmZ d dlmZmZmZ e	e dœdd„Zeeef dœdd	„Zeeef dœd
d„Zde
eef ddœdd„Zedœdd„Zedkræejeƒ ƒ dS )é    N)ÚDictÚOptionalÚUnion)ÚJSONSerializable)ÚVERSIONSÚ_get_versionÚimport_optional_dependency)Úreturnc              C   s   ddl m}  | ƒ }|d S )za
    Use vendored versioneer code to get git hash, which handles
    git worktree correctly.
    r   )Úget_versionszfull-revisionid)Zpandas._versionr
   )r
   Úversions© r   ú?/tmp/pip-install-4cy230dp/pandas/pandas/util/_print_versions.pyÚ_get_commit_hash   s    r   c              C   sr   t jƒ } tjƒ \}}tƒ djdd„ tjD ƒƒtj	dƒd | j
| j| j| j| jtjtjjdƒtjjdƒ||dœd	œS )
zG
    Returns system information as a JSON serializable dictionary.
    Ú.c             s   s   | ]}t |ƒV  qd S )N)Ústr)Ú.0Úir   r   r   ú	<genexpr>!   s    z _get_sys_info.<locals>.<genexpr>ÚPé   ÚLC_ALLÚLANG)zlanguage-codeÚencoding)ÚcommitÚpythonzpython-bitsZOSz
OS-releaseÚVersionÚmachineÚ	processorÚ	byteorderr   r   ÚLOCALE)ÚplatformÚunameÚlocaleÚ	getlocaler   ÚjoinÚsysÚversion_infoÚstructÚcalcsizeÚsystemÚreleaseÚversionr   r   r   ÚosÚenvironÚget)Úuname_resultÚlanguage_coder   r   r   r   Ú_get_sys_info   s    

r1   c              C   sr   ddddddddd	d
ddddddddddg} | j ttƒƒ i }x.| D ]&}t|ddd�}|rbt|ƒnd||< qDW |S )zK
    Returns dependency information as a JSON serializable dictionary.
    ZpandasZnumpyZpytzZdateutilÚpipÚ
setuptoolsZCythonZpytestZ
hypothesisZsphinxZbloscZfeatherZ
xlsxwriterz
lxml.etreeÚhtml5libZpymysqlZpsycopg2Zjinja2ZIPythonZpandas_datareaderFÚignore)Zraise_on_missingZ
on_versionN)ÚextendÚlistr   r   r   )ÚdepsÚresultÚmodnameÚmodr   r   r   Ú_get_dependency_info/   s6    
r<   F)Úas_jsonr	   c       
      C   s6  t ƒ }tƒ }| rjt||d�}| dkr.t|ƒ n:t| tƒs<t‚tj| ddd��}t	j
||dd� W dQ R X nÈt|d	 tƒs|t‚|d	 d
 }|d	 d }|› d|› �|d	< tdd„ |D ƒƒ}tdƒ tdƒ x.|jƒ D ]"\}}	t|d|› �›d|	› �ƒ qÒW tdƒ x0|jƒ D ]$\}}	t|d|› �›d|	› �ƒ �q
W dS )a  
    Provide useful information, important for bug reports.

    It comprises info about hosting operation system, pandas version,
    and versions of other installed relative packages.

    Parameters
    ----------
    as_json : str or bool, default False
        * If False, outputs info in a human readable form to the console.
        * If str, it will be considered as a path to a file.
          Info will be written to that file in JSON format.
        * If True, outputs info in JSON format to the console.
    )r)   ZdependenciesTÚwbÚutf8)r   é   )ÚindentNr   zlanguage-coder   r   c             s   s   | ]}t |ƒV  qd S )N)Úlen)r   Úxr   r   r   r   |   s    z show_versions.<locals>.<genexpr>z
INSTALLED VERSIONSz------------------ú<z: Ú )r1   r<   ÚdictÚprintÚ
isinstancer   ÚAssertionErrorÚcodecsÚopenÚjsonÚdumpÚmaxÚitems)
r=   Zsys_infor8   ÚjÚfr0   r   ÚmaxlenÚkÚvr   r   r   Úshow_versionsZ   s*    
rU   c              C   sR   ddl m}  | ƒ }|jdddddd� |jƒ \}}|jd	krBd
|_t|jd� dS )Nr   )ÚOptionParserz-jz--jsonÚFILEé   z>Save output as JSON into file, pass in '-' to output to stdout)ÚmetavarÚnargsÚhelpú-T)r=   )ÚoptparserV   Ú
add_optionÚ
parse_argsrL   rU   )rV   ÚparserÚoptionsÚargsr   r   r   Úmain†   s    
rc   Ú__main__)F)rJ   rL   r"   r,   r    r'   r%   Útypingr   r   r   Zpandas._typingr   Zpandas.compat._optionalr   r   r   r   r   r1   r<   ÚboolrU   Úintrc   Ú__name__Úexitr   r   r   r   Ú<module>   s    +,