
    ^h	                     B    S r SSKrSSKrSSKrSSKrSSKrS rS rS rg)zQ
Utilities for getting information about Jupyter and the system it's running in.
    Nc                    [         R                  nSnU nX#:w  a  UnUR                  UR                  US5      5      (       aq   [        R
                  " / SQ[        R                  [        R                  U S9nUR                  5       u  pVU(       a!  SUR                  5       R                  S5      4$ gUR                  U5      nX#:w  a  M  g! [         a    Sn NPf = f)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          Q/home/james-whalen/.local/lib/python3.13/site-packages/jupyter_server/_sysinfo.pypkg_commit_hashr       s    , 	AHH

88AFF8V,--	#!'';%??%?? 	 "&!1!1!3 #[%6%6%8%?%?%HHH99X&% 
(   #"#s   AC CCc           
          [        U 5      u  p[        R                  U UU[        R                  [        R
                  [        R                  [        R                  " 5       [        R                  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
)	jupyter_server_versionjupyter_server_pathcommit_sourcecommit_hashsys_versionsys_executablesys_platformplatformos_name)	r    jupyter_server__version__sysversion
executabler)   r   name)r   srchshs      r   pkg_infor3   ?   sT     x(HC"0"<"<'{{..%%'77
 
    c            	          [         R                  n U R                  U R                  U R	                  U R                  [        R                  5      5      5      5      n[        U5      $ )z5Return useful information about the system as a dict.)	r   r   realpathr   abspathr   r+   __file__r3   )r   r   s     r   get_sys_infor9   Z   sD    
A::aii		!&&1H1H*I JKLDD>r4   )	__doc__r   r)   r   r-   r+   r    r3   r9    r4   r   <module>r<      s+    
   
 -`6r4   