From ca88e5bc1d03137626ecd2887800b75ef273f421 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 16 Sep 2024 01:17:55 +0200 Subject: [PATCH 1/4] doc/quiet --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 462a1d5..1d231ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,7 @@ path = "rwx/__init__.py" [tool.pydoclint] allow-init-docstring = true +quiet = true skip-checking-short-docstrings = false style = "sphinx" From 450e10e2f4d82997baf6942f98aa18d3ca48d435 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 16 Sep 2024 11:14:40 +0200 Subject: [PATCH 2/4] class,os --- rwx/__init__.py | 17 +++++++++++++++++ rwx/os/abstract.py | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/rwx/__init__.py b/rwx/__init__.py index a1c5ee6..ee9f51e 100644 --- a/rwx/__init__.py +++ b/rwx/__init__.py @@ -1,3 +1,20 @@ """Read Write eXecute.""" __version__ = "0.0.1" + + +class Class: + """Root class.""" + + def __repr__(self) -> str: + """Represent object variables. + + :return: representation + :rtype: str + """ + name = self.__class__.__name__ + attributes = [ + f"{k}={v!r}" for k, v in vars(self).items() if not k.startswith("_") + ] + arguments = ", ".join(attributes) + return f"{name}({arguments})" diff --git a/rwx/os/abstract.py b/rwx/os/abstract.py index e985dc5..8b99c28 100644 --- a/rwx/os/abstract.py +++ b/rwx/os/abstract.py @@ -3,8 +3,10 @@ from abc import ABC, abstractmethod from pathlib import Path +from rwx import Class -class OS(ABC): + +class OS(Class, ABC): """Operating System.""" def __init__(self, path: Path) -> None: From b7eec788f7b0a77355835a323516adaa5b19aacd Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 16 Sep 2024 11:35:29 +0200 Subject: [PATCH 3/4] =?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"""\ From 487d7cb9b2edd5d9d7f058da427c8e2db5a45176 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 16 Sep 2024 12:04:43 +0200 Subject: [PATCH 4/4] str --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index a8a258c..e2beac8 100644 --- a/readme.md +++ b/readme.md @@ -52,6 +52,7 @@ A tiny framework to read, write & execute things. ### Task stack * character constants for box drawing +* common __str__ function * parse pyproject.toml to write commands * write classes for * steps bars to log