Compare commits
4 commits
26fea93bdb
...
487d7cb9b2
Author | SHA1 | Date | |
---|---|---|---|
487d7cb9b2 | |||
b7eec788f7 | |||
450e10e2f4 | |||
ca88e5bc1d |
8 changed files with 32 additions and 14 deletions
|
@ -33,6 +33,7 @@ path = "rwx/__init__.py"
|
||||||
|
|
||||||
[tool.pydoclint]
|
[tool.pydoclint]
|
||||||
allow-init-docstring = true
|
allow-init-docstring = true
|
||||||
|
quiet = true
|
||||||
skip-checking-short-docstrings = false
|
skip-checking-short-docstrings = false
|
||||||
style = "sphinx"
|
style = "sphinx"
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ A tiny framework to read, write & execute things.
|
||||||
### Task stack
|
### Task stack
|
||||||
|
|
||||||
* character constants for box drawing
|
* character constants for box drawing
|
||||||
|
* common __str__ function
|
||||||
* parse pyproject.toml to write commands
|
* parse pyproject.toml to write commands
|
||||||
* write classes for
|
* write classes for
|
||||||
* steps bars to log
|
* steps bars to log
|
||||||
|
|
|
@ -1,3 +1,20 @@
|
||||||
"""Read Write eXecute."""
|
"""Read Write eXecute."""
|
||||||
|
|
||||||
__version__ = "0.0.1"
|
__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})"
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
"""Handle errors."""
|
"""Handle errors."""
|
||||||
|
|
||||||
|
from rwx import Class
|
||||||
|
|
||||||
class Error(Exception):
|
|
||||||
|
class Error(Class, Exception):
|
||||||
"""Parent class for all errors."""
|
"""Parent class for all errors."""
|
||||||
|
|
|
@ -3,8 +3,10 @@
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from rwx import Class
|
||||||
|
|
||||||
class OS(ABC):
|
|
||||||
|
class OS(Class, ABC):
|
||||||
"""Operating System."""
|
"""Operating System."""
|
||||||
|
|
||||||
def __init__(self, path: Path) -> None:
|
def __init__(self, path: Path) -> None:
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
|
from rwx import Class
|
||||||
from rwx.ps import Command
|
from rwx.ps import Command
|
||||||
|
|
||||||
|
|
||||||
class PM(ABC):
|
class PM(Class, ABC):
|
||||||
"""Package Manager."""
|
"""Package Manager."""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
|
|
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from rwx import Class
|
||||||
|
|
||||||
class Project:
|
|
||||||
|
class Project(Class):
|
||||||
"""Parent class for any type of project."""
|
"""Parent class for any type of project."""
|
||||||
|
|
||||||
def __init__(self, file: Path) -> None:
|
def __init__(self, file: Path) -> None:
|
||||||
|
@ -13,10 +15,6 @@ class Project:
|
||||||
self.root: Path = self.file.parent
|
self.root: Path = self.file.parent
|
||||||
self.name: str = self.root.name
|
self.name: str = self.root.name
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
"""Represent project."""
|
|
||||||
return f"Project(file={self.raw!r})"
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
"""Return file, root & name."""
|
"""Return file, root & name."""
|
||||||
return f"""\
|
return f"""\
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from rwx import txt
|
from rwx import Class, txt
|
||||||
|
|
||||||
|
|
||||||
class Command:
|
class Command(Class):
|
||||||
"""Command to run."""
|
"""Command to run."""
|
||||||
|
|
||||||
def __init__(self, *arguments: str | tuple[str, ...]) -> None:
|
def __init__(self, *arguments: str | tuple[str, ...]) -> None:
|
||||||
|
@ -13,10 +13,6 @@ class Command:
|
||||||
self.raw = arguments
|
self.raw = arguments
|
||||||
self.flat: list[str] = []
|
self.flat: list[str] = []
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
|
||||||
"""Represent command."""
|
|
||||||
return f"Command({self.raw!r})"
|
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
"""Return raw & flat."""
|
"""Return raw & flat."""
|
||||||
return f"""\
|
return f"""\
|
||||||
|
|
Loading…
Reference in a new issue