
    ^j                     L    d Z ddlZddlZddlmZmZ ddededz  fdZdefdZy)	z'Package version and git-status helpers.    N)PackageNotFoundErrorversionpackage_namereturnc                 8    	 t        |       S # t        $ r Y yw xY w)a  Get the current version of the specified package.

    Args:
        package_name: The name of the package to get the version for. Defaults to ``'rfdetr'``.

    Returns:
        The version string of the specified package, or ``None`` if the version cannot be determined.
    N)r   r   )r   s    c/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/rfdetr/utilities/package.pyget_versionr	      s$    |$$ s   
 	c                  $   t         j                  j                  t         j                  j                  t                    dt
        t           dt        ffd} 	  | g d      }t        j                  g dddd      }|j                  d	vr9t        j                  |j                  g d|j                  |j                  
      |j                  dk(  }|rdnd} | g d      }d| d| d| S # t        j                  t        f$ r Y yw xY w)zReturn a short status string for the current git repo, or 'unknown' if unavailable.

    Returns:
        String describing the current git HEAD, status, and branch.
    commandr   c                 l    t        j                  |       j                  d      j                         S )N)cwdascii)
subprocesscheck_outputdecodestrip)r   r   s    r   _runzget_sha.<locals>._run$   s*    &&wC8??HNNPP    )git	rev-parseHEAD)r   z
diff-indexz--quietr   z--FT)r   checkcapture_outputtext)r      )
returncodecmdoutputstderrr   zhas uncommitted changesclean)r   r   z--abbrev-refr   zsha: z
, status: z
, branch: unknown)ospathdirnameabspath__file__liststrr   runr   CalledProcessErrorstdoutr   FileNotFoundError)r   shadiff_resulthas_diffstatusbranchr   s         @r   get_shar2      s
    ''//"''//(3
4CQd3i QC Q/0 nn:
 !!///&11B"))"))	  ))Q..6*GBCse:fXZx@@))+<= s   BC3 3DD)rfdetr)	__doc__r"   r   importlib.metadatar   r   r(   r	   r2    r   r   <module>r7      s6    . 	  <c t    r   