o
    Ñ­jx&  ã                   @  s2  d dl mZ d dlZd dlmZmZmZmZ ddlm	Z	m
Z
mZ ddlmZmZmZ g d¢Zd1d
d„Zeed eeef f ZedeƒZ	 G dd„ deƒZG dd„ deƒZG dd„ deƒZe dejejB ¡Ze dej¡Ze dej¡Zddœd2dd„Z d3dd „Z!d!d"œd4d&d'„Z"dd(œd5d,d-„Z#d6d/d0„Z$dS )7é    )ÚannotationsN)ÚNewTypeÚTupleÚUnionÚcasté   )ÚTagÚUnsortedTagsErrorÚ	parse_tag)ÚInvalidVersionÚVersionÚ_TrimmedRelease)
ÚBuildTagÚInvalidNameÚInvalidSdistFilenameÚInvalidWheelFilenameÚNormalizedNameÚcanonicalize_nameÚcanonicalize_versionÚis_normalized_nameÚparse_sdist_filenameÚparse_wheel_filenameÚreturnú	list[str]c                   C  s   t S )N)Ú__all__© r   r   úL/var/www/html/CropPilot/venv/lib/python3.10/site-packages/packaging/utils.pyÚ__dir__   s   r   r   r   c                   @  ó   e Zd ZdZdS )r   zW
    An invalid distribution name; users should refer to the packaging user guide.
    N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   '   ó    r   c                   @  r   )r   zM
    An invalid wheel filename was found, users should refer to PEP 427.
    Nr   r   r   r   r   r   -   r$   r   c                   @  r   )r   z^
    An invalid sdist filename was found, users should refer to the packaging user guide.
    Nr   r   r   r   r   r   3   r$   r   z%[a-z0-9]|[a-z0-9][a-z0-9._-]*[a-z0-9]z+[a-z0-9]|[a-z0-9]([a-z0-9-](?!--))*[a-z0-9]z	(\d+)(.*)F)ÚvalidateÚnameÚstrr%   Úboolc                C  sZ   |rt  | ¡std| ›�ƒ‚|  ¡  dd¡ dd¡}d|v r(| dd¡}d|v std|ƒS )a]  
    This function takes a valid Python package or extra name, and returns the
    normalized form of it.

    The return type is typed as :class:`NormalizedName`. This allows type
    checkers to help require that a string has passed through this function
    before use.

    If **validate** is true, then the function will check if **name** is a valid
    distribution name before normalizing.

    :param str name: The name to normalize.
    :param bool validate: Check whether the name is a valid distribution name.
    :raises InvalidName: If **validate** is true and the name is not an
        acceptable distribution name.

    >>> from packaging.utils import canonicalize_name
    >>> canonicalize_name("Django")
    'django'
    >>> canonicalize_name("oslo.concurrency")
    'oslo-concurrency'
    >>> canonicalize_name("requests")
    'requests'
    zname is invalid: Ú_ú-Ú.z--r   )Ú_validate_regexÚ	fullmatchr   ÚlowerÚreplacer   )r&   r%   Úvaluer   r   r   r   B   s   ÿ
r   c                 C  s   t  | ¡duS )a7  
    Check if a name is already normalized (i.e. :func:`canonicalize_name` would
    roundtrip to the same value).

    :param str name: The name to check.

    >>> from packaging.utils import is_normalized_name
    >>> is_normalized_name("requests")
    True
    >>> is_normalized_name("Django")
    False
    N)Ú_normalized_regexr-   )r&   r   r   r   r   g   s   r   T)Ústrip_trailing_zeroÚversionúVersion | strr2   c                C  sH   t | tƒrzt| ƒ} W n ty   t| ƒ Y S w t|r!t| ƒƒS | ƒS )a  Return a canonical form of a version as a string.

    This function takes a string representing a package version (or a
    :class:`~packaging.version.Version` instance), and returns the
    normalized form of it. By default, it strips trailing zeros from
    the release segment.

    >>> from packaging.utils import canonicalize_version
    >>> canonicalize_version('1.0.1')
    '1.0.1'

    Per PEP 625, versions may have multiple canonical forms, differing
    only by trailing zeros.

    >>> canonicalize_version('1.0.0')
    '1'
    >>> canonicalize_version('1.0.0', strip_trailing_zero=False)
    '1.0.0'

    Invalid versions are returned unaltered.

    >>> canonicalize_version('foo bar baz')
    'foo bar baz'

    >>> canonicalize_version('1.4.0.0.0')
    '1.4'
    )Ú
isinstancer'   r   r   r   )r3   r2   r   r   r   r   w   s   
ÿr   ©Úvalidate_orderÚfilenamer7   ú8tuple[NormalizedName, Version, BuildTag, frozenset[Tag]]c             
   C  sf  |   d¡std| ›�ƒ‚| dd… } |  d¡}|dvr"td| ›�ƒ‚|  d|d ¡}|d	 }d
|v s<t d|tj¡du rCtd| ›�ƒ‚t|ƒ}zt|d ƒ}W n t	yc } ztd| ›�ƒ|‚d}~ww |dkr�|d }t
 |¡}	|	du rtd|› d| ›�ƒ‚tdt|	 d¡ƒ|	 d¡fƒ}
nd}
|d }zt||d�}W n ty¬   td| ›�ƒd‚w |||
|fS )a  
    This function takes the filename of a wheel file, and parses it,
    returning a tuple of name, version, build number, and tags.

    The name part of the tuple is normalized and typed as
    :class:`NormalizedName`. The version portion is an instance of
    :class:`~packaging.version.Version`. The build number is ``()`` if
    there is no build number in the wheel filename, otherwise a
    two-item tuple of an integer for the leading digits and
    a string for the rest of the build number. The tags portion is a
    frozen set of :class:`~packaging.tags.Tag` instances (as the tag
    string format allows multiple tags to be combined into a single
    string).

    If **validate_order** is true, compressed tag set components are
    checked to be in sorted order as required by PEP 425.

    :param str filename: The name of the wheel file.
    :param bool validate_order: Check whether compressed tag set components
        are in sorted order.
    :raises InvalidWheelFilename: If the filename in question
        does not follow the :ref:`wheel specification
        <pypug:binary-distribution-format>`.

    >>> from packaging.utils import parse_wheel_filename
    >>> from packaging.tags import Tag
    >>> from packaging.version import Version
    >>> name, ver, build, tags = parse_wheel_filename("foo-1.0-py3-none-any.whl")
    >>> name
    'foo'
    >>> ver == Version('1.0')
    True
    >>> tags == {Tag("py3", "none", "any")}
    True
    >>> not build
    True

    .. versionadded:: 26.1
       The *validate_order* parameter.
    z.whlz3Invalid wheel filename (extension must be '.whl'): Néüÿÿÿr*   )é   é   z0Invalid wheel filename (wrong number of parts): é   r   Ú__z^[\w\d._]*$zInvalid project name: r   z*Invalid wheel filename (invalid version): r<   zInvalid build number: z in r   r   éÿÿÿÿr6   z\Invalid wheel filename (compressed tag set components must be in sorted order per PEP 425): )Úendswithr   ÚcountÚsplitÚreÚmatchÚUNICODEr   r   r   Ú_build_tag_regexr   ÚintÚgroupr
   r	   )r8   r7   ÚdashesÚpartsÚ	name_partr&   r3   ÚeÚ
build_partÚbuild_matchÚbuildÚtag_strÚtagsr   r   r   r   �   s^   
-ÿ
ÿÿþ€ÿ
ÿ ÿÿýÿr   útuple[NormalizedName, Version]c              
   C  s°   |   d¡r| dtdƒ … }n|   d¡r| dtdƒ … }ntd| ›�ƒ‚| d¡\}}}|s6td| ›�ƒ‚t|ƒ}z	t|ƒ}W ||fS  tyW } ztd| ›�ƒ|‚d}~ww )a‘  
    This function takes the filename of a sdist file (as specified
    in the `Source distribution format`_ documentation), and parses
    it, returning a tuple of the normalized name and version as
    represented by an instance of :class:`~packaging.version.Version`.

    :param str filename: The name of the sdist file.
    :raises InvalidSdistFilename: If the filename does not end
        with an sdist extension (``.zip`` or ``.tar.gz``), or if it does not
        contain a dash separating the name and the version of the distribution.

    >>> from packaging.utils import parse_sdist_filename
    >>> from packaging.version import Version
    >>> name, ver = parse_sdist_filename("foo-1.0.tar.gz")
    >>> name
    'foo'
    >>> ver == Version('1.0')
    True

    .. _Source distribution format: https://packaging.python.org/specifications/source-distribution-format/#source-distribution-file-name
    z.tar.gzNz.zipz@Invalid sdist filename (extension must be '.tar.gz' or '.zip'): r*   zInvalid sdist filename: z*Invalid sdist filename (invalid version): )r@   Úlenr   Ú
rpartitionr   r   r   )r8   Ú	file_stemrK   ÚsepÚversion_partr&   r3   rL   r   r   r   r   ù   s0   

ÿÿ
ûÿþ€ÿr   )r   r   )r&   r'   r%   r(   r   r   )r&   r'   r   r(   )r3   r4   r2   r(   r   r'   )r8   r'   r7   r(   r   r9   )r8   r'   r   rR   )%Ú
__future__r   rC   Útypingr   r   r   r   rQ   r   r	   r
   r3   r   r   r   r   r   rG   r'   r   r   Ú
ValueErrorr   r   r   ÚcompileÚ
IGNORECASEÚASCIIr,   r1   rF   r   r   r   r   r   r   r   r   r   Ú<module>   s2   

ÿ
%ÿ)ý\