a
    ç´«j·/  ã                   @  sf  d dl mZ d dlZd dlmZmZmZ ddlmZm	Z	m
Z
mZ ddlmZmZmZ g d¢Zdd	œd
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 e dej!¡Z"ddœddddœdd„Z#dddœd d!„Z$d"d#œd$ddd%œd&d'„Z%dd(œddd)d*œd+d,„Z&dd-d.œd/d0„Z'dS )1é    )ÚannotationsN)ÚNewTypeÚUnionÚcasté   )Ú
InvalidTagÚTagÚUnsortedTagsErrorÚ	parse_tag)ÚInvalidVersionÚVersionÚ_TrimmedRelease)
ÚBuildTagÚInvalidNameÚInvalidSdistFilenameÚInvalidWheelFilenameÚNormalizedNameÚcanonicalize_nameÚcanonicalize_versionÚis_normalized_nameÚparse_sdist_filenameÚparse_wheel_filenamez	list[str])Úreturnc                   C  s   t S )N)Ú__all__© r   r   úN/var/www/html/laksyashrimp/venv/lib/python3.9/site-packages/packaging/utils.pyÚ__dir__   s    r   r   r   c                   @  s   e Zd ZdZdS )r   zs
    An invalid distribution name; users should refer to the packaging user guide.

    .. versionadded:: 23.2
    N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   .   s   r   c                   @  s   e Zd ZdZdS )r   zi
    An invalid wheel filename was found, users should refer to PEP 427.

    .. versionadded:: 20.9
    Nr   r   r   r   r   r   6   s   r   c                   @  s   e Zd ZdZdS )r   zz
    An invalid sdist filename was found, users should refer to the packaging user guide.

    .. versionadded:: 20.9
    Nr   r   r   r   r   r   >   s   r   z%[a-z0-9]|[a-z0-9][a-z0-9._-]*[a-z0-9]z[a-z0-9]+(?:-[a-z0-9]+)*z	(\d+)(.*)z
^[\w._]+\ZF)ÚvalidateÚstrÚbool)Únamer"   r   c                C  sT   |rt  | ¡std| ›�ƒ‚|  ¡  dd¡ dd¡}d|v rJ| dd¡}q4t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'

    .. versionadded:: 16.2

    .. versionchanged:: 20.4
       The return type was changed to :class:`NormalizedName`.

    .. versionchanged:: 23.2
       Added the *validate* keyword parameter.
    zname is invalid: Ú_ú-Ú.z--r   )Ú_validate_regexÚ	fullmatchr   ÚlowerÚreplacer   )r%   r"   Úvaluer   r   r   r   R   s    !r   )r%   r   c                 C  s   t  | ¡duS )a5  
    Check if a name is a normalized project name (i.e. a valid name that
    :func:`canonicalize_name` would roundtrip to the same value).

    The roundtrip only characterizes normalized names for *valid* names. A name
    must start and end with an ASCII letter or digit, which
    :func:`canonicalize_name` does not enforce: it leaves a leading or trailing
    hyphen in place, so such a name roundtrips without being normalized.

    :param str name: The name to check.

    >>> from packaging.utils import canonicalize_name, is_normalized_name
    >>> is_normalized_name("requests")
    True
    >>> is_normalized_name("Django")
    False
    >>> canonicalize_name("_not_legal")
    '-not-legal'
    >>> is_normalized_name("-not-legal")  # roundtrips, but not a valid name
    False

    .. versionadded:: 23.2
    N)Ú_normalized_regexr*   )r%   r   r   r   r      s    r   T)Ústrip_trailing_zerozVersion | str)Úversionr/   r   c                C  sF   t | tƒr2zt| ƒ} W n ty0   t| ƒ Y S 0 t|r@t| ƒn| ƒ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'

    .. versionadded:: 17.1

    .. versionchanged:: 21.0
       The return type was narrowed to :class:`str`.

    .. versionchanged:: 22.0
       Added the *strip_trailing_zero* keyword parameter.
    )Ú
isinstancer#   r   r   r   )r0   r/   r   r   r   r   š   s    &
r   ©Úvalidate_orderz8tuple[NormalizedName, Version, BuildTag, frozenset[Tag]])Úfilenamer3   r   c             
   C  s˜  |   d¡std| ›�ƒ‚| dd… } |  d¡}|dvrDtd| ›�ƒ‚|  d|d ¡}|d	 }d
|v srt |¡du r€td| ›�ƒ‚t|ƒ}zt|d ƒ}W n4 tyÌ } ztd| ›�ƒ|‚W Y d}~n
d}~0 0 |dk�r(|d }t	 |¡}	|	du �rtd|› d| ›�ƒ‚t
dt|	 d¡ƒ|	 d¡fƒ}
nd}
|d }zt||d�}W nF t�yh   td| ›�ƒd‚Y n$ t�yŠ   td| ›�ƒd‚Y n0 |||
|fS )am  
    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:: 20.9

    .. versionchanged:: 23.2
       Raises :class:`InvalidWheelFilename` when the version component is invalid.

    .. versionadded:: 26.1
       The *validate_order* parameter.

    .. versionchanged:: 26.3
       Raises :class:`InvalidWheelFilename` when an interpreter component is
       not an identifier, a tag set component is empty, or the project name is
       empty.
    z.whlz3Invalid wheel filename (extension must be '.whl'): Néüÿÿÿr'   )é   é   z0Invalid wheel filename (wrong number of parts): é   r   Ú__zInvalid project name: r   z*Invalid wheel filename (invalid version): r7   zInvalid build number: z in r   r   éÿÿÿÿr2   z\Invalid wheel filename (compressed tag set components must be in sorted order per PEP 425): z0Invalid wheel filename (invalid tag component): )Úendswithr   ÚcountÚsplitÚ_wheel_name_regexÚmatchr   r   r   Ú_build_tag_regexr   ÚintÚgroupr
   r	   r   )r4   r3   ÚdashesÚpartsÚ	name_partr%   r0   ÚeÚ
build_partÚbuild_matchÚbuildÚtag_strÚtagsr   r   r   r   È   sd    7
ÿ
ÿÿþ


ÿ ÿÿýÿþr   ztuple[NormalizedName, Version])r4   r   c              
   C  sÐ   |   d¡r| dtdƒ … }n,|   d¡r<| dtdƒ … }ntd| ›�ƒ‚| d¡\}}}|sltd| ›�ƒ‚|s~td| ›�ƒ‚t|ƒ}zt|ƒ}W n4 tyÆ } ztd| ›�ƒ|‚W Y d}~n
d}~0 0 ||fS )	a5  
    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``), if it does not
        contain a dash separating the name and the version of the distribution,
        if the project name is empty, or if the version portion is not a valid
        version.

    >>> 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

    .. versionadded:: 20.9

    .. versionchanged:: 21.0
       Added support for ``.zip`` source distributions.

    .. versionchanged:: 23.2
       Raises :class:`InvalidSdistFilename` when the version component is invalid.

    .. versionchanged:: 26.3
       Raises :class:`InvalidSdistFilename` on an empty project name.

    .. _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 (empty project name): z*Invalid sdist filename (invalid version): )r;   Úlenr   Ú
rpartitionr   r   r   )r4   Ú	file_stemrE   ÚsepÚversion_partr%   r0   rF   r   r   r   r   2  s4    #

ÿÿÿÿþr   )(Ú
__future__r   ÚreÚtypingr   r   r   rK   r   r   r	   r
   r0   r   r   r   r   r   ÚtuplerA   r#   r   r   Ú
ValueErrorr   r   r   ÚcompileÚ
IGNORECASEÚASCIIr)   r.   r@   ÚUNICODEr>   r   r   r   r   r   r   r   r   r   Ú<module>   s0   
	ÿ-ÿ1ýj