From b7eec788f7b0a77355835a323516adaa5b19aacd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 16 Sep 2024 11:35:29 +0200 Subject: [PATCH] =?UTF-8?q?=E2=88=92repr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rwx/err/__init__.py | 4 +++- rwx/os/pm/__init__.py | 3 ++- rwx/prj/__init__.py | 8 +++----- rwx/ps/__init__.py | 8 ++------ 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/rwx/err/__init__.py b/rwx/err/__init__.py index 294d8d8..53a63c7 100644 --- a/rwx/err/__init__.py +++ b/rwx/err/__init__.py @@ -1,5 +1,7 @@ """Handle errors.""" +from rwx import Class -class Error(Exception): + +class Error(Class, Exception): """Parent class for all errors.""" diff --git a/rwx/os/pm/__init__.py b/rwx/os/pm/__init__.py index d248e47..b3cacc4 100644 --- a/rwx/os/pm/__init__.py +++ b/rwx/os/pm/__init__.py @@ -2,10 +2,11 @@ from abc import ABC, abstractmethod +from rwx import Class from rwx.ps import Command -class PM(ABC): +class PM(Class, ABC): """Package Manager.""" def __init__(self) -> None: diff --git a/rwx/prj/__init__.py b/rwx/prj/__init__.py index f4a8acb..3cba90b 100644 --- a/rwx/prj/__init__.py +++ b/rwx/prj/__init__.py @@ -2,8 +2,10 @@ from pathlib import Path +from rwx import Class -class Project: + +class Project(Class): """Parent class for any type of project.""" def __init__(self, file: Path) -> None: @@ -13,10 +15,6 @@ class Project: self.root: Path = self.file.parent self.name: str = self.root.name - def __repr__(self) -> str: - """Represent project.""" - return f"Project(file={self.raw!r})" - def __str__(self) -> str: """Return file, root & name.""" return f"""\ diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 54d58cf..601aca3 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -2,10 +2,10 @@ import subprocess -from rwx import txt +from rwx import Class, txt -class Command: +class Command(Class): """Command to run.""" def __init__(self, *arguments: str | tuple[str, ...]) -> None: @@ -13,10 +13,6 @@ class Command: self.raw = arguments self.flat: list[str] = [] - def __repr__(self) -> str: - """Represent command.""" - return f"Command({self.raw!r})" - def __str__(self) -> str: """Return raw & flat.""" return f"""\