
    he                        d Z ddlZddlZddlZddlZddgZej                            e          Z	d Z
d Zd Zd Z e            xZZ ej        d	e          Zee                                neZed
k    rddlmZ  e             dS dS )z
Scapy: create, send, sniff, dissect and manipulate network packets.

Usable either from an interactive console or as a Python library.
https://scapy.net
    NVERSION__version__c                    t          j        d|           }|r-|                    d          d|                    d          S t          j        d|           }|rd|                    d          z  S t          d          )z~
    Parse a tag from ``git describe`` into a version.

    Example::

        v2.3.2-346-g164a52c075c8 -> '2.3.2.dev346'
    z^v?(.+?)-(\d+)-g[a-f0-9]+$   z.dev   z^v?([\d\.]+(rc\d+)?)$z%sztag has invalid format)rematchgroup
ValueError)tagr	   s     R/mounts/lovelace/software/anaconda3/lib/python3.11/site-packages/scapy/__init__.py
_parse_tagr      s     H2C88E 	7"[[^^^^U[[^^^<<3S99 	75;;q>>**5666    c                     d                                 } | d         }t          |           dk    r	| d         }nd}d|v rt          d          d|v rd}|rt          |          S |rQt          j                            t          |          t          j        j                  }|	                    d          S t          d	          )
z
    Rely on git archive "export-subst" git attribute.
    See 'man gitattributes' for more details.
    Note: describe is only supported with git >= 2.32.0,
    and the `tags=true` option with git >= 2.35.0 but we
    use it to workaround GH#3121.
    z"$Format:%ct %(describe:tags=true)$r   r    Formatznot a git archivedescribe%Y.%m.%dzinvalid git archive format)
splitlenr   r   datetimefromtimestampinttimezoneutcstrftime)git_archive_idtstampr   ds       r   _version_from_git_archiver    0   s     :??AANAF
>QQ 6,---S
 &#	 &++CKK9J9NOOzz*%%%
1
2
22r   c                  t   t           j                            t           j                            t           j                            t
                    d                    st          d          d }  | d          }|                    d          s | d          } | d|z            }t          |          S )a  
    Read the version from ``git describe``. It returns the latest tag with an
    optional suffix if the current directory is not exactly on the tag.

    Example::

        $ git describe --always
        v2.3.2-346-g164a52c075c8

    The tag prefix (``v``) and the git commit sha1 (``-g164a52c075c8``) are
    removed if present.

    If the current directory is not exactly on the tag, a ``.devN`` suffix is
    appended where N is the number of commits made after the last tag.

    Example::

        >>> _version_from_git_describe()
        '2.3.2.dev346'

    :raises CalledProcessError: if git is unavailable
    :return: Scapy's latest tag
    z.gitznot in scapy git repoc                 L   t          j        |                                 t          t           j        t           j                  }|                                \  }}|j        dk    r&|                                                                S t          j	        |j        |          )N)cwdstdoutstderrr   )

subprocessPopenr   _SCAPY_PKG_DIRPIPEcommunicate
returncodedecodestripCalledProcessError)cmdprocessouterrs       r   _gitz(_version_from_git_describe.<locals>._gitn   s    "IIKK??	
 
 
 &&((S""::<<%%'''/0BCHHHr   z#git describe --tags --always --longvz!git rev-list --tags --max-count=1z&git describe --tags --always --long %s)	ospathisdirjoindirnamer(   r   
startswithr   )r3   r   commits      r   _version_from_git_describer<   R   s    2 7==bgoon&E&EvNNOO 20111I I I $4
5
5C>># F9::d;fDEEc??r   c                     	 t           j        d         S # t          $ r Y nw xY wt           j                            t
          d          } 	 t          | d          5 }|                                }ddd           n# 1 swxY w Y   |S # t          t          f$ r Y nw xY w	 t                      S # t          $ r Y nw xY w	 t                      S # t          $ r Y nw xY w	 t          j                            t           j                            t"                    t          j        j                  }|                    d          S # t          $ r Y nw xY wdS )zTReturns the Scapy version from multiple methods

    :return: the Scapy version
    SCAPY_VERSIONr   rNr   z0.0.0)r5   environKeyErrorr6   r8   r(   openreadFileNotFoundErrorNotADirectoryErrorr    r   r<   	Exceptionr   r   getmtime__file__r   r   r   )version_filefdsecr   r   s       r   _versionrK      s   z/**    7<<	::L,$$ 	**,,C	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
12   (***   )+++   ++GX&&(9(=
 
 zz*%%%    7sy    
!!
B A;/B ;A??B A?B BB B. .
B;:B;?C 
CCA%E 
EEz([0-9]|\.[0-9])+__main__)interact)__doc__r   r5   r   r&   __all__r6   r9   rH   r(   r   r    r<   rK   r   r   search_tmpr
   VERSION_MAIN__name__
scapy.mainrM    r   r   <module>rV      s     				 				     
 **7 7 7,3 3 3D/ / /d. . .b !

 "+ry$g..#/tzz|||Wz######HJJJJJ r   