
    @=d	                     h    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mZ ddl	Z	ddl	m
Z
 d Zd Zd ZdS )zQ
Utilities for getting information about Jupyter and the system it's running in.
    N)	py3compatencoding)_versionc                    t           j        }d}| }||k    r|}|                    |                    |d                    r	 t	          j        g dt          j        t          j        |           }|                                \  }}n# t          $ r d}Y nw xY w|r)d|	                                
                    d          fS dS |                    |          }||k    dS )a  Get short form of commit hash given directory `pkg_path`

    We get the commit hash from git if it's a repo.

    If this 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
    Nz.git)gitz	rev-parsez--shortHEAD)stdoutstderrcwd
repositoryascii) r   )ospathexistsjoin
subprocessPopenPIPEcommunicateOSErrorstripdecodedirname)pkg_pathpcur_pathpar_pathprocrepo_commit_s          2lib/python3.11/site-packages/nbclassic/_sysinfo.pypkg_commit_hashr#      s   , 	AHH
h

88AFF8V,,-- 	#!'(O(O(O+5?+5?(02 2 2 "&!1!1!3!3QQ # # #"#  #[%6%6%8%8%?%?%H%HHHv99X&&! h

$ 6s   AB	 	BBc                     t          |           \  }}t          t          | ||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
    )
notebook_versionnotebook_pathcommit_sourcecommit_hashsys_versionsys_executablesys_platformplatformos_namedefault_encoding)r#   dictr   sysversion
executabler,   r   namer   DEFAULT_ENCODING)r   srchshs      r"   pkg_infor7   A   s^     x((HC!K~\"$$!2
 
 
 
    c            	          t           j        } |                     |                     |                     |                     t          j                                                }t          |          S )z5Return useful information about the system as a dict.)	r   r   realpathr   abspathr   	nbclassic__file__r7   )r   r   s     r"   get_sys_infor>   \   sM    
A::aii		!&&1C*D*D E EFFGGDD>>r8   )__doc__r   r,   pprintr0   r   ipython_genutilsr   r   r<   r   r#   r7   r>    r8   r"   <module>rC      s     
			   



     0 0 0 0 0 0 0 0          + + +\
 
 
6    r8   