o
    i	                     @   sl   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d Zdd Zd	d
 ZdS )zQ
Utilities for getting information about Jupyter and the system it's running in.
    N)	py3compatencoding)_versionc                 C   s   t j}d}| }||krM|}|||drDztjg dtjtj| d}| \}}W n ty6   d}Y nw |rBd|	 
dfS dS ||}||ks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_ r    M/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/nbclassic/_sysinfo.pypkg_commit_hash   s,   

r"   c                 C   s6   t | \}}tt| ||tjtjtjt tjt	j
d
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hshr    r    r!   pkg_infoA   s   r5   c               	   C   s,   t j} | | | | tj}t|S )z5Return useful information about the system as a dict.)	r   r   realpathr   abspathr   	nbclassic__file__r5   )r   r   r    r    r!   get_sys_info\   s   r:   )__doc__r   r*   pprintr.   r   ipython_genutilsr   r   r8   r   r"   r5   r:   r    r    r    r!   <module>   s    .