Commit bca120fe authored by Steve Kowalik's avatar Steve Kowalik

Update to the newest packaging, and collapse _parse_requirement_specs

parent 792edda4
...@@ -2873,10 +2873,7 @@ class RequirementParseError(ValueError): ...@@ -2873,10 +2873,7 @@ class RequirementParseError(ValueError):
def _parse_requirement_specs(req): def _parse_requirement_specs(req):
if req.specifier:
return [(spec.operator, spec.version) for spec in req.specifier] return [(spec.operator, spec.version) for spec in req.specifier]
else:
return []
def parse_requirements(strs): def parse_requirements(strs):
......
...@@ -48,11 +48,13 @@ VERSION_PEP440 = Regex(Specifier._regex_str, re.VERBOSE | re.IGNORECASE) ...@@ -48,11 +48,13 @@ VERSION_PEP440 = Regex(Specifier._regex_str, re.VERBOSE | re.IGNORECASE)
VERSION_LEGACY = Regex(LegacySpecifier._regex_str, re.VERBOSE | re.IGNORECASE) VERSION_LEGACY = Regex(LegacySpecifier._regex_str, re.VERBOSE | re.IGNORECASE)
VERSION_ONE = VERSION_PEP440 | VERSION_LEGACY VERSION_ONE = VERSION_PEP440 | VERSION_LEGACY
VERSION_MANY = VERSION_ONE + ZeroOrMore(COMMA + VERSION_ONE) VERSION_MANY = Combine(VERSION_ONE + ZeroOrMore(COMMA + VERSION_ONE),
VERSION_MANY.setParseAction( joinString=",")("_raw_spec")
lambda s, l, t: SpecifierSet(','.join(t.asList())) _VERSION_SPEC = Optional(((LPAREN + VERSION_MANY + RPAREN) | VERSION_MANY))
) _VERSION_SPEC.setParseAction(lambda s, l, t: t._raw_spec or '')
VERSION_SPEC = ((LPAREN + VERSION_MANY + RPAREN) | VERSION_MANY)("specifier")
VERSION_SPEC = originalTextFor(_VERSION_SPEC)("specifier")
VERSION_SPEC.setParseAction(lambda s, l, t: t[1])
MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker") MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker")
MARKER_EXPR.setParseAction( MARKER_EXPR.setParseAction(
...@@ -61,7 +63,7 @@ MARKER_EXPR.setParseAction( ...@@ -61,7 +63,7 @@ MARKER_EXPR.setParseAction(
MARKER_SEPERATOR = SEMICOLON MARKER_SEPERATOR = SEMICOLON
MARKER = MARKER_SEPERATOR + MARKER_EXPR MARKER = MARKER_SEPERATOR + MARKER_EXPR
VERSION_AND_MARKER = Optional(VERSION_SPEC) + Optional(MARKER) VERSION_AND_MARKER = VERSION_SPEC + Optional(MARKER)
URL_AND_MARKER = URL + Optional(MARKER) URL_AND_MARKER = URL + Optional(MARKER)
NAMED_REQUIREMENT = \ NAMED_REQUIREMENT = \
...@@ -94,7 +96,7 @@ class Requirement(object): ...@@ -94,7 +96,7 @@ class Requirement(object):
else: else:
self.url = None self.url = None
self.extras = req.extras.asList() if req.extras else [] self.extras = req.extras.asList() if req.extras else []
self.specifier = req.specifier if req.specifier else None self.specifier = SpecifierSet(req.specifier)
self.marker = req.marker if req.marker else None self.marker = req.marker if req.marker else None
def __str__(self): def __str__(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment