Skip to content

Commit

Permalink
Preserve requirement_string in ParsedRequirement class
Browse files Browse the repository at this point in the history
  • Loading branch information
elikoga committed May 15, 2024
1 parent 716a935 commit 1149608
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/appenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,19 @@ def ensure_best_python(base):


class ParsedRequirement:
"""A parsed requirement from a requirement string.
def __init__(self, name, url=None):
Has a similiar interface to the real Requirement class from
packaging.requirements, but is reduced to the parts we need.
"""

def __init__(self, name, url, requirement_string):
self.name = name
self.url = url
self.requirement_string = requirement_string

def __str__(self):
return self.name
return self.requirement_string


def parse_requirement_string(requirement_string):
Expand Down Expand Up @@ -278,7 +284,7 @@ def parse_requirement_string(requirement_string):
f"(?:{whitespace_regex})?;?", requirement_string)
url = url_match.group('url') if url_match else None

return ParsedRequirement(name, url)
return ParsedRequirement(name, url, requirement_string)


class AppEnv(object):
Expand Down

0 comments on commit 1149608

Please sign in to comment.