From 450e10e2f4d82997baf6942f98aa18d3ca48d435 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 16 Sep 2024 11:14:40 +0200 Subject: [PATCH] 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: