bix&ddlmZddlZddlmZmZmZmZddlm Z m Z m Z ddl m Z mZmZgdZd+d Zeed eeeffZed eZ Gd deZGddeZGddeZejdejejzZejdejZejdejZddd,dZ d-dZ!ddd.d#Z"dd$d/d(Z#d0d*Z$dS)1) annotationsN)NewTypeTupleUnioncast)TagUnsortedTagsError parse_tag)InvalidVersionVersion_TrimmedRelease) BuildTag InvalidNameInvalidSdistFilenameInvalidWheelFilenameNormalizedNamecanonicalize_namecanonicalize_versionis_normalized_nameparse_sdist_filenameparse_wheel_filenamereturn list[str]ctS)N)__all__g/home/jenkins/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/packaging/utils.py__dir__r s NrrrceZdZdZdS)rzW An invalid distribution name; users should refer to the packaging user guide. N__name__ __module__ __qualname____doc__rrrrr'rrceZdZdZdS)rzM An invalid wheel filename was found, users should refer to PEP 427. Nr"rrrrr-r'rrceZdZdZdS)rz^ An invalid sdist filename was found, users should refer to the packaging user guide. Nr"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)validatenamestrr*boolc2|r,t|std||dddd}d|vr|dd}d|vt 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' zname is invalid: _-.z--r)_validate_regex fullmatchrlowerreplacer)r+r*values rrrBs2811$7786d66777 JJLL c * * 2 23 < >> from packaging.utils import is_normalized_name >>> is_normalized_name("requests") True >>> is_normalized_name("Django") False N)_normalized_regexr3)r+s rrrgs  & &t , ,D 88rT)strip_trailing_zeroversion Version | strr9ct|tr0 t|}n#t$rt|cYSwxYwt|rt |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)r:r9s rrrwsx<'3  g&&GG   w<<    +>Kw'''G L LLs'AAvalidate_orderfilenamer?8tuple[NormalizedName, Version, BuildTag, frozenset[Tag]]c|dstd||dd}|d}|dvrtd||d|dz }|d }d |vs t jd |tjtd |t|} t|d }n%#t$r}td||d}~wwxYw|dkr|d}t|} | td|d|tdt| d | df} nd} |d} t| |} n!#t$rtd|dwxYw||| | fS)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 `. >>> 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'): Nr0)z0Invalid wheel filename (wrong number of parts): r__z ^[\w\d._]*$zInvalid project name: rz*Invalid wheel filename (invalid version): rEzInvalid build number: z in rrr>z\Invalid wheel filename (compressed tag set components must be in sorted order per PEP 425): )endswithrcountsplitrematchUNICODErr r _build_tag_regexrintgroupr r ) r@r?dashesparts name_partr+r:e build_part build_matchbuildtag_strtagss rrrsGZ   V $ $ " N( N N   }H ^^C F V" Kx K K    NN3 + +EaI yBH^Y KKS"#HH#H#HIII Y ' 'D%(## " E E E    {{1X &,,Z88  &EEEEE Z#k&7&7&:&:";";[=N=Nq=Q=Q!RSSBiG@@@ " 7*2 7 7    '5$ ''s$C C<$C77C<F!!F?tuple[NormalizedName, Version]c|dr|dtd }n@|dr|dtd }ntd||d\}}}|std|t |} t |}n%#t $r}td||d}~wwxYw||fS)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'): r0zInvalid sdist filename: z*Invalid sdist filename (invalid version): )rIlenr rpartitionrr r )r@ file_stemrTsep version_partr+r:rUs rrrs.,## .I./   6 " " ^F |^, "      $-#7#7#<#< IsL L"#Jh#J#JKKK Y ' 'D,'' " E E E    '?s,B<< CCC)rr)r+r,r*r-rr)r+r,rr-)r:r;r9r-rr,)r@r,r?r-rrA)r@r,rr[)% __future__rrLtypingrrrrrZr r r r:r r rrr rPr,rr ValueErrorrrrcompile IGNORECASEASCIIr2r8rOrrrrrrrrrhsV #""""" ............3333333333==========    rE#s(O+ ,)3// * : :"*,bmbh.FBJMrxXX2:lBH556;")")")")")")J 9 9 9 9"<@#M#M#M#M#M#MR!Y(Y(Y(Y(Y(Y(x//////r