Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
utils.cpython-313.pyc163 linesDownload Raw Back to __pycache__
1�

2
�jx&���SSKJr SSKrSSKJrJrJrJr SSKJ	r	J3r4Jr SSKJ
r
JrJr /SQrSSjr\\S	\\\44r\"S5\5r"SS\5r"S
S\5r"SS\5r\R4"S\R6\R8-5r\R4"S\R85r\R4"S\R85rSS.SSjjr S Sjr!SS.S!Sjjr"SS.S"Sjjr#S#Sjr$g)$�)�annotationsN)�NewType�Tuple�Union�cast�)�Tag�UnsortedTagsError�	parse_tag)�InvalidVersion�Version�_TrimmedRelease)6�BuildTag�InvalidName�InvalidSdistFilename�InvalidWheelFilename�NormalizedName�canonicalize_name�canonicalize_version�is_normalized_name�parse_sdist_filename�parse_wheel_filenamec��[$)N)�__all__���UD:\code\apps\devtools\python\user_packages\Python313\site-packages\packaging/utils.py�__dir__rs���Nrrrc��\rSrSrSrSrg)r�'zO7An invalid distribution name; users should refer to the packaging user guide.8rN��__name__�9__module__�__qualname__�__firstlineno__�__doc__�__static_attributes__rrrrr'���rrc��\rSrSrSrSrg)r�-zE10An invalid wheel filename was found, users should refer to PEP 427.11rNr!rrrrr-r(rrc��\rSrSrSrSrg)r�3zV12An invalid sdist filename was found, users should refer to the packaging user guide.13rNr!rrrrr3r(rrz%[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)�validatec��U(a)[RU5(d[SU<35eUR5R	SS5R	SS5nSU;aUR	SS5nSU;aM[SU5$)a14This function takes a valid Python package or extra name, and returns the15normalized form of it.16 17The return type is typed as :class:`NormalizedName`. This allows type18checkers to help require that a string has passed through this function19before use.20 21If **validate** is true, then the function will check if **name** is a valid22distribution name before normalizing.23 24:param str name: The name to normalize.25:param bool validate: Check whether the name is a valid distribution name.26:raises InvalidName: If **validate** is true and the name is not an27    acceptable distribution name.28 29>>> from packaging.utils import canonicalize_name30>>> canonicalize_name("Django")31'django'32>>> canonicalize_name("oslo.concurrency")33'oslo-concurrency'34>>> canonicalize_name("requests")35'requests'36zname is invalid: �_�-�.z--r)�_validate_regex�	fullmatchr�lower�replacer)�namer-�values   rrrBs��2��1�1�$�7�7��-�d�X�6�7�7�
�J�J�L� � ��c�*�2�2�3��<�E�37�%�-��
�
�d�C�(���%�-�� �%�(�(rc�0�[RU5SL$)a38Check if a name is already normalized (i.e. :func:`canonicalize_name` would39roundtrip to the same value).40 41:param str name: The name to check.42 43>>> from packaging.utils import is_normalized_name44>>> is_normalized_name("requests")45True46>>> is_normalized_name("Django")47False48N)�_normalized_regexr3)r6s rrrgs���&�&�t�,�D�8�8rT)�strip_trailing_zeroc��[U[5(a[U5n[U(a[	U55$U5$![a [U5s$f=f)a�Return a canonical form of a version as a string.49 50This function takes a string representing a package version (or a51:class:`~packaging.version.Version` instance), and returns the52normalized form of it. By default, it strips trailing zeros from53the release segment.54 55>>> from packaging.utils import canonicalize_version56>>> canonicalize_version('1.0.1')57'1.0.1'58 59Per PEP 625, versions may have multiple canonical forms, differing60only by trailing zeros.61 62>>> canonicalize_version('1.0.0')63'1'64>>> canonicalize_version('1.0.0', strip_trailing_zero=False)65'1.0.0'66 67Invalid versions are returned unaltered.68 69>>> canonicalize_version('foo bar baz')70'foo bar baz'71 72>>> canonicalize_version('1.4.0.0.0')73'1.4'74)�75isinstance�strr
rr)�versionr:s  rrrwsX��<�'�3���	 ��g�&�G��+>��w�'�L�L�G�L�L���	 ��w�<��	 �s�A�A�A��validate_orderc��URS5(d[SU<35eUSSnURS5nUS;a[SU<35eURSUS-765nUS	nS77U;d'[R78"SU[R5c[SU<35e[U5n[US
5nUS:XaeUSn[RU5n	U	c[SUSU<35e[S[U	RS
55U	RS545n79OSn80USn[X�S9nXVX�4$![an[SU<35UeSnAff=f![a [SU<35Sef=f)a�81This function takes the filename of a wheel file, and parses it,82returning a tuple of name, version, build number, and tags.83 84The name part of the tuple is normalized and typed as85:class:`NormalizedName`. The version portion is an instance of86:class:`~packaging.version.Version`. The build number is ``()`` if87there is no build number in the wheel filename, otherwise a88two-item tuple of an integer for the leading digits and89a string for the rest of the build number. The tags portion is a90frozen set of :class:`~packaging.tags.Tag` instances (as the tag91string format allows multiple tags to be combined into a single92string).93 94If **validate_order** is true, compressed tag set components are95checked to be in sorted order as required by PEP 425.96 97:param str filename: The name of the wheel file.98:param bool validate_order: Check whether compressed tag set components99    are in sorted order.100:raises InvalidWheelFilename: If the filename in question101    does not follow the :ref:`wheel specification102    <pypug:binary-distribution-format>`.103 104>>> from packaging.utils import parse_wheel_filename105>>> from packaging.tags import Tag106>>> from packaging.version import Version107>>> name, ver, build, tags = parse_wheel_filename("foo-1.0-py3-none-any.whl")108>>> name109'foo'110>>> ver == Version('1.0')111True112>>> tags == {Tag("py3", "none", "any")}113True114>>> not build115True116 117.. versionadded:: 26.1118   The *validate_order* parameter.119z.whlz3Invalid wheel filename (extension must be '.whl'): N�����r0)��z0Invalid wheel filename (wrong number of parts): �r�__z^[\w\d._]*$zInvalid project name: rz*Invalid wheel filename (invalid version): rDzInvalid build number: z in rr�����r?z\Invalid wheel filename (compressed tag set components must be in sorted order per PEP 425): )�endswithr�count�split�re�match�UNICODErr
r�_build_tag_regexr�int�grouprr120)
�filenamer@�dashes�parts�	name_partr6r>�e�121build_part�build_match�build�tag_str�tagss
             rrr�s���Z���V�$�$�"�A�(��N�122�	123����}�H�
�^�^�C�
 �F�
�V��"�>�x�l�K�124�	125�
�N�N�3���126�+�E��a��I��y��B�H�H�^�Y��127�128�K�S�"�%;�H�<�#H�I�I��Y�'�D���%��(�#����{��1�X�129�&�,�,�Z�8����&�(���D���E��
��Z�#�k�&7�&7��&:�";�[�=N�=N�q�=Q�!R�S�����B�i�G����@��
�5�'�'��/��"�8���E�130��	����$��"�*�*2��
7�131��	��s$�3E�4	E#�132E �E�E �#E>c��URS5(aUS[S5*nO5URS5(aUS[S5*nO[SU<35eURS5up#nU(d[SU<35e[	U5n[U5nXV4$![an[SU<35UeSnAff=f)aM133This function takes the filename of a sdist file (as specified134in the `Source distribution format`_ documentation), and parses135it, returning a tuple of the normalized name and version as136represented by an instance of :class:`~packaging.version.Version`.137 138:param str filename: The name of the sdist file.139:raises InvalidSdistFilename: If the filename does not end140    with an sdist extension (``.zip`` or ``.tar.gz``), or if it does not141    contain a dash separating the name and the version of the distribution.142 143>>> from packaging.utils import parse_sdist_filename144>>> from packaging.version import Version145>>> name, ver = parse_sdist_filename("foo-1.0.tar.gz")146>>> name147'foo'148>>> ver == Version('1.0')149True150 151.. _Source distribution format: https://packaging.python.org/specifications/source-distribution-format/#source-distribution-file-name152z.tar.gzNz.zipz@Invalid sdist filename (extension must be '.tar.gz' or '.zip'): r0zInvalid sdist filename: z*Invalid sdist filename (invalid version): )rH�lenr�153rpartitionrr
r)rQ�	file_stemrT�sep�version_partr6r>rUs        rrr�s���,����#�#��.��I���/�	�	�	�	�6�	"�	"��^��F��|�,�	�"���|�
�154�	155�$-�#7�#7��#<� �I�L��"�%=�h�\�#J�K�K��Y�'�D���,�'��
�?�����"�8���E�156��	���s�B � 157B?�*B:�:B?)�returnz	list[str])r6r=r-�boolrar)r6r=rarb)r>z
Version | strr:rbrar=)rQr=r@rbraz8tuple[NormalizedName, Version, BuildTag, frozenset[Tag]])rQr=raztuple[NormalizedName, Version])%�158__future__rrK�typingrrrrrZr	r159rr>rr
rrrrOr=rr�160ValueErrorrrr�compile�161IGNORECASE�ASCIIr2r9rNrrrrrrrr�<module>ris5��162#�	�.�.�3�3�=�=������r��E�#�s�(�O�+�,���)�3�/���163�*���:���:���*�*�,�b�m�m�b�h�h�.F����J�J�M�r�x�x�X���:�:�l�B�H�H�5��6;�")�J
9�"<@�#M�
�#M�48�#M��#M�R!�Y(��Y(��Y(�>�	Y(�x/r
codekingpro/portable-devtools · Team Ai