From 67414fce3d5558380cffb9d8fc06f3983d24ecd2 Mon Sep 17 00:00:00 2001 From: lucaseck <117225985+lucaseck@users.noreply.github.com> Date: Tue, 9 Jul 2024 13:44:01 -0500 Subject: [PATCH] chore: update dependency parsing logic Signed-off-by: lucaseck <117225985+lucaseck@users.noreply.github.com> --- scripts/_project.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/scripts/_project.py b/scripts/_project.py index ab6a0d6..7e3a687 100644 --- a/scripts/_project.py +++ b/scripts/_project.py @@ -30,23 +30,14 @@ def get_project_dict(project_path: Optional[Path] = None) -> dict[str, Any]: class Dependency: name: str - operator: Optional[str] - version: Optional[str] + pip_requirement: str def __init__(self, dep: str): - components = dep.split(" ") - self.name = components[0] - if len(components) > 2: - self.operator = components[1] - self.version = components[2] - else: - self.operator = None - self.version = None + self.pip_requirement = dep.strip().split(";", maxsplit=1)[0].replace(" ", "") + self.name = dep.strip().split(" ", maxsplit=1)[0] def for_pip(self) -> str: - if self.operator is not None and self.version is not None: - return f"{self.name}{self.operator}{self.version}" - return self.name + return self.pip_requirement def __repr__(self) -> str: return self.for_pip()