
    Xh                         d 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 ddlm	Z	 ddl
mZmZ dedeeef   fdZdedefd	Zdefd
ZdefdZy)zQ
Utilities for getting information about IPython and the system it's running in.
    N)Path)release)_sysinfoencodingpkg_pathreturnc                 <   t         j                  rdt         j                  fS t        j                  dj	                  d      t        j
                  t        j
                  |       }|j                         \  }}|r!d|j                         j                  d      fS y)a"  Get short form of commit hash given directory `pkg_path`

    We get the commit hash from (in order of preference):

    * IPython.utils._sysinfo.commit
    * git output, if we are in a git repository

    If these fail, we return a not-found placeholder tuple

    Parameters
    ----------
    pkg_path : str
        directory containing package
        only used for getting commit from active repo

    Returns
    -------
    hash_from : str
        Where we got the hash from - description
    hash_str : str
        short form of hash
    installationzgit rev-parse --short HEAD )stdoutstderrcwd
repositoryascii)z(none found)z<not found>)	r   commit
subprocessPopensplitPIPEcommunicatestripdecode)r   procrepo_commit_s       I/var/www/html/myenv/lib/python3.12/site-packages/IPython/utils/sysinfo.pypkg_commit_hashr       s    0 x.. 8>>sC#-??#-?? (*D %%'NK[..077@@@(    c                    t        |       \  }}t        t        j                  | ||t        j                  t        j
                  t        j                  t        j                         t        j                  t        j                  
      S )zReturn dict describing the context of this package

    Parameters
    ----------
    pkg_path : str
        path containing __init__.py for package

    Returns
    -------
    context : dict
        with named parameters of interest
    )
ipython_versionipython_pathcommit_sourcecommit_hashsys_versionsys_executablesys_platformplatformos_namedefault_encoding)r   dictr   versionsys
executabler'   osnamer   DEFAULT_ENCODING)r   srchshs      r   pkg_infor3   F   s`     x(HCKK~~\\""$!22
 
r   c                  z    t        t        d      j                         j                  } t	        t        |             S )zBReturn useful information about IPython and the system, as a dict.z..)r   __file__resolveparentr3   str)paths    r   get_sys_infor:   a   s,    $'')00DCIr   c                  <    t        j                  t                     S )au  Return useful information about IPython and the system, as a string.

    Examples
    --------
    ::
    
        In [2]: print(sys_info())
        {'commit_hash': '144fdae',      # random
         'commit_source': 'repository',
         'ipython_path': '/home/fperez/usr/lib/python2.6/site-packages/IPython',
         'ipython_version': '0.11.dev',
         'os_name': 'posix',
         'platform': 'Linux-2.6.35-22-generic-i686-with-Ubuntu-10.10-maverick',
         'sys_executable': '/usr/bin/python',
         'sys_platform': 'linux2',
         'sys_version': '2.6.6 (r266:84292, Sep 15 2010, 15:52:39) \n[GCC 4.4.5]'}
    )pprintpformatr:    r   r   sys_infor?   f   s    $ >>,.))r   )__doc__r.   r'   r<   r,   r   pathlibr   IPython.corer   IPython.utilsr   r   r8   tupler   r*   r3   r:   r?   r>   r   r   <module>rE      sk    
   
     ,#)c #)eCHo #)L
s 
t 
6d 
*# *r   