Skip to content

Commit

Permalink
Better parsing of requirements.txt lines (#846)
Browse files Browse the repository at this point in the history
  • Loading branch information
garethsb authored Feb 23, 2024
1 parent 4b52578 commit 17df30d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion nmostesting/NMOSTesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,14 @@ def run_noninteractive_tests(args):
return exit_code


def get_package_name(requirement):
pattern = r'^([^\s>=<]+)'
match = re.match(pattern, requirement)
if match:
return match.group(1)
return None


def check_internal_requirements():
corrections = {"gitpython": "git",
"pyopenssl": "OpenSSL",
Expand All @@ -976,7 +984,7 @@ def check_internal_requirements():
installed_pkgs = [pkg[1] for pkg in pkgutil.iter_modules()]
with open("requirements.txt") as requirements_file:
for requirement in requirements_file.readlines():
requirement_name = requirement.strip().split(">")[0]
requirement_name = get_package_name(requirement)
if requirement_name in corrections:
corrected_req = corrections[requirement_name]
else:
Expand Down

0 comments on commit 17df30d

Please sign in to comment.