diff --git a/rwx/__init__.py b/rwx/__init__.py index 50c7cbe..ee9f51e 100644 --- a/rwx/__init__.py +++ b/rwx/__init__.py @@ -2,16 +2,14 @@ __version__ = "0.0.1" -from os import linesep - class Class: """Root class.""" def __repr__(self) -> str: - """Return machine-readable state. + """Represent object variables. - :return: state + :return: representation :rtype: str """ name = self.__class__.__name__ @@ -20,14 +18,3 @@ class Class: ] arguments = ", ".join(attributes) return f"{name}({arguments})" - - def __str__(self) -> str: - """Return human-readable state. - - :return: state - :rtype: str - """ - attributes = [ - f"{k} = {v}" for k, v in vars(self).items() if not k.startswith("_") - ] - return linesep.join(attributes) diff --git a/rwx/os/abstract.py b/rwx/os/abstract.py index f4837fc..8b99c28 100644 --- a/rwx/os/abstract.py +++ b/rwx/os/abstract.py @@ -17,3 +17,10 @@ class OS(Class, ABC): @abstractmethod def get_name(self) -> str: """Return mandatory name.""" + + def __str__(self) -> str: + """Return root & name.""" + return f"""\ +root = {self.root} +name = {self.name} +""" diff --git a/rwx/os/pm/__init__.py b/rwx/os/pm/__init__.py index 6236ee6..b3cacc4 100644 --- a/rwx/os/pm/__init__.py +++ b/rwx/os/pm/__init__.py @@ -21,3 +21,10 @@ class PM(Class, ABC): @abstractmethod def get_install_command(self) -> Command: """Command to install package(s).""" + + def __str__(self) -> str: + """Return commands.""" + return f"""\ + clean = {self.clean} +install = {self.install} +""" diff --git a/rwx/prj/__init__.py b/rwx/prj/__init__.py index c0251e2..3cba90b 100644 --- a/rwx/prj/__init__.py +++ b/rwx/prj/__init__.py @@ -14,3 +14,12 @@ class Project(Class): self.file = self.raw.resolve() self.root: Path = self.file.parent self.name: str = self.root.name + + def __str__(self) -> str: + """Return file, root & name.""" + return f"""\ + raw = {self.raw} +file = {self.file} +root = {self.root} +name = {self.name} +""" diff --git a/rwx/ps/__init__.py b/rwx/ps/__init__.py index 584c50d..601aca3 100644 --- a/rwx/ps/__init__.py +++ b/rwx/ps/__init__.py @@ -13,6 +13,13 @@ class Command(Class): self.raw = arguments self.flat: list[str] = [] + def __str__(self) -> str: + """Return raw & flat.""" + return f"""\ + raw = {self.raw} +flat = {self.flat} +""" + def get_tuples_args(*items: str | tuple[str, ...]) -> list[str]: """Turn arguments tuples into an arguments list."""