o
    Ba_                     @   s   d Z ddlm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	Z	ddl
mZ zddlmZ W n eyA   dZdZdZY n	w ddlZddlZdd Zd	d
 Zdd Zedkr_e  dS dS )z'Module containing bug report helper(s).    )print_functionN   )__version__)	pyopensslc                  C   s   t  } | dkrt  }n5| dkr.dtjjtjjtjjf }tjjdkr-d	|tjjg}n| dkr7t  }n| dkr@t  }nd}| |d	S )
a  Return a dict with the Python implementation and version.

    Provide both the name and the version of the Python implementation
    currently running. For example, on CPython 2.7.5 it will return
    {'name': 'CPython', 'version': '2.7.5'}.

    This function works best on CPython and PyPy: in particular, it probably
    doesn't work for Jython or IronPython. Future investigation should be done
    to work out the correct shape of the code for those platforms.
    CPythonPyPyz%s.%s.%sfinal Jython
IronPythonUnknown)nameversion)
platformpython_implementationpython_versionsyspypy_version_infomajorminormicroreleaseleveljoin)implementationimplementation_version r   //usr/lib/python3/dist-packages/requests/help.py_implementation   s&   



r   c            	      C   s   zt  t  d} W n ty   ddd} Y nw t }dtji}dtji}ddd}tr8tjdtj	j
 d}dttddi}dttddi}tj
}d|durTd| ndi}| ||tdu|||||dtid	
S )
z&Generate information for a bug report.)systemreleaser   r   Nr	   )r   openssl_versionz%xr   )
r   r   
system_sslusing_pyopenssl	pyOpenSSLurllib3chardetcryptographyidnarequests)r   r   r   IOErrorr   r$   r   r%   OpenSSLSSLOPENSSL_VERSION_NUMBERgetattrr&   r'   sslr   requests_version)	platform_infoimplementation_infourllib3_infochardet_infopyopenssl_infocryptography_info	idna_infor!   system_ssl_infor   r   r   info;   sL   




r8   c                   C   s   t tjt ddd dS )z)Pretty-print the bug information as JSON.T   )	sort_keysindentN)printjsondumpsr8   r   r   r   r   mainq   s   r?   __main__)__doc__
__future__r   r=   r   r   r.   r'   r$   r%   r	   r   r/   urllib3.contribr   ImportErrorr*   r&   r   r8   r?   __name__r   r   r   r   <module>   s2    !6
