Skip to content

Commit

Permalink
chore: update dependency parsing logic
Browse files Browse the repository at this point in the history
Signed-off-by: lucaseck <[email protected]>
  • Loading branch information
lucaseck committed Jul 9, 2024
1 parent 05b74b3 commit 67414fc
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions scripts/_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 67414fc

Please sign in to comment.