This commit is contained in:
lz_db
2026-10-16 22:48:30 +08:00
parent 190de72571
commit 0b36fd3383
3161 changed files with 12787 additions and 77274 deletions
@@ -1,9 +1,9 @@
"""Module for parsing and testing package version predicate strings."""
import operator
"""Module for parsing and testing package version predicate strings.
"""
import re
import distutils.version
import operator
from . import version
re_validPackage = re.compile(r"(?i)^\s*([a-z_]\w*(?:\.[a-z_]\w*)*)(.*)", re.ASCII)
# (package) (rest)
@@ -20,10 +20,10 @@ def splitUp(pred):
"""
res = re_splitComparison.match(pred)
if not res:
raise ValueError(f"bad package restriction syntax: {pred!r}")
raise ValueError("bad package restriction syntax: %r" % pred)
comp, verStr = res.groups()
with version.suppress_known_deprecation():
other = version.StrictVersion(verStr)
with distutils.version.suppress_known_deprecation():
other = distutils.version.StrictVersion(verStr)
return (comp, other)
@@ -113,17 +113,17 @@ class VersionPredicate:
raise ValueError("empty package restriction")
match = re_validPackage.match(versionPredicateStr)
if not match:
raise ValueError(f"bad package name in {versionPredicateStr!r}")
raise ValueError("bad package name in %r" % versionPredicateStr)
self.name, paren = match.groups()
paren = paren.strip()
if paren:
match = re_paren.match(paren)
if not match:
raise ValueError(f"expected parenthesized list: {paren!r}")
raise ValueError("expected parenthesized list: %r" % paren)
str = match.groups()[0]
self.pred = [splitUp(aPred) for aPred in str.split(",")]
if not self.pred:
raise ValueError(f"empty parenthesized list in {versionPredicateStr!r}")
raise ValueError("empty parenthesized list in %r" % versionPredicateStr)
else:
self.pred = []
@@ -167,9 +167,9 @@ def split_provision(value):
value = value.strip()
m = _provision_rx.match(value)
if not m:
raise ValueError(f"illegal provides specification: {value!r}")
raise ValueError("illegal provides specification: %r" % value)
ver = m.group(2) or None
if ver:
with version.suppress_known_deprecation():
ver = version.StrictVersion(ver)
with distutils.version.suppress_known_deprecation():
ver = distutils.version.StrictVersion(ver)
return m.group(1), ver