From 033898ccc095eeed2c453899f06a515e21be934a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 10 Jun 2024 21:10:51 +0200 Subject: [PATCH] prj/str --- cd/__init__.py | 2 ++ cd/project.py | 8 ++++++++ cd/projects.py | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/cd/__init__.py b/cd/__init__.py index fb08438..cced3c9 100644 --- a/cd/__init__.py +++ b/cd/__init__.py @@ -12,7 +12,9 @@ from cd.projects import Projects COMMANDS_PREFIX = "cd-" projects = Projects() +print(projects) project = Project(projects) +print(project) def cd_browse_workspace() -> None: diff --git a/cd/project.py b/cd/project.py index 680b7d9..3981ee7 100644 --- a/cd/project.py +++ b/cd/project.py @@ -40,3 +40,11 @@ class Project: self.root = value # url self.url = urljoin(projects.url, self.name) + + def __str__(self: Project) -> str: + return """\ +branch = {self.branch} + name = {self.name} + root = {self.root} + url = {self.url} +""" diff --git a/cd/projects.py b/cd/projects.py index d2e0d5d..971f7a8 100644 --- a/cd/projects.py +++ b/cd/projects.py @@ -29,3 +29,10 @@ class Projects: for variable in SERVER_URL: if value := self.environment.get(variable, None): self.url = urljoin(value, self.group) + + def __str__(self: Projects) -> str: + return """\ +group = {self.group} + name = {self.name} + url = {self.url} +"""