a
    b3jx&                     @  sX  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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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.d/Z$dS )0    )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_filenamez	list[str])returnc                   C  s   t S )N)__all__ r   r   l/www/wwwroot/dpstar/app/297b3aabda72fedb274352021c2dd8b5_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   zW
    An invalid distribution name; users should refer to the packaging user guide.
    N__name__
__module____qualname____doc__r   r   r   r   r   '   s   r   c                   @  s   e Zd ZdZdS )r   zM
    An invalid wheel filename was found, users should refer to PEP 427.
    Nr   r   r   r   r   r   -   s   r   c                   @  s   e Zd ZdZdS )r   z^
    An invalid sdist filename was found, users should refer to the packaging user guide.
    Nr   r   r   r   r   r   3   s   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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'
    zname is invalid: _-.z--r   )_validate_regex	fullmatchr   lowerreplacer   )r%   r"   valuer   r   r   r   B   s    r   )r%   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_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'
    )
isinstancer#   r   r   r   )r0   r/   r   r   r   r   w   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 sxtd|tjdu rt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 n$ tyn   td| dY n0 |||
|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'): Nr'   )      z0Invalid wheel filename (wrong number of parts):    r   __z^[\w\d._]*$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): )endswithr   countsplitrematchUNICODEr   r   r   _build_tag_regexr   intgroupr
   r	   )r4   r3   dashesparts	name_partr%   r0   e
build_partbuild_matchbuildZtag_strtagsr   r   r   r      sX    -




 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| t|}zt|}W n4 ty } ztd| |W Y d}~n
d}~0 0 ||fS )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   )r4   	file_stemrF   sepversion_partr%   r0   rG   r   r   r   r      s,    

r   )%
__future__r   r>   typingr   r   r   r   rK   r   r	   r
   r0   r   r   r   r   r   rB   r#   r   r   
ValueErrorr   r   r   compile
IGNORECASEASCIIr)   r.   rA   r   r   r   r   r   r   r   r   r   <module>   s.   
%)\