Compare commits

..

No commits in common. "db47d5c80a70253b584a3cefcee35dc97bf194ea" and "4e369df232f527dc9640e1a55373453d70f0feb6" have entirely different histories.

10 changed files with 17 additions and 140 deletions

View file

@ -31,11 +31,6 @@ requires-python = ">= 3.11"
[tool.hatch.version]
path = "rwx/__init__.py"
[tool.pydoclint]
allow-init-docstring = true
skip-checking-short-docstrings = false
style = "sphinx"
[tool.ruff]
line-length = 80

View file

@ -4,10 +4,6 @@ import sys
def split() -> tuple[str, list[str]]:
"""Split command & actual arguments.
:return: both
:rtype: tuple[str, list[str]]
"""
"""Split command & actual arguments."""
command, *arguments = sys.argv
return command, arguments

View file

@ -1,15 +1,11 @@
"""Control Operating Systems."""
from os import sep
from pathlib import Path
from .abstract import OS
from .debian import Debian
class OS:
"""Operating System."""
def from_path(path: Path) -> OS:
"""Initialize from an already existing path."""
return Debian(path)
up = from_path(Path(sep))
def __init__(self, path: str) -> None:
"""Set root."""
self.root = Path(path)

View file

@ -1,24 +0,0 @@
"""Abstract Operating System."""
from abc import ABC, abstractmethod
from pathlib import Path
class OS(ABC):
"""Operating System."""
def __init__(self, path: Path) -> None:
"""Set root."""
self.root = path
self.name = self.get_name()
@abstractmethod
def get_name(self) -> str:
"""Return mandatory name."""
def __str__(self) -> str:
"""Return root & name."""
return f"""\
root = {self.root}
name = {self.name}
"""

View file

@ -1,11 +0,0 @@
"""Debian operating system."""
from .abstract import OS
class Debian(OS):
"""Debian operating system."""
def get_name(self) -> str:
"""Return name."""
return "Debian"

View file

@ -1,29 +0,0 @@
"""Package Manager."""
from abc import ABC, abstractmethod
from rwx.ps import Command
class PM(ABC):
"""Package Manager."""
def __init__(self) -> None:
"""Set commands."""
self.clean = self.get_clean_command()
self.install = self.get_install_command()
@abstractmethod
def get_clean_command(self) -> Command:
"""Command to clean packages cache."""
@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}
"""

View file

@ -1,16 +0,0 @@
"""Advanced Package Tool."""
from rwx.os.pm import PM
from rwx.ps import Command
class APT(PM):
"""Advanced Package Tool."""
def get_clean_command(self) -> Command:
"""Return clean command."""
return Command()
def get_install_command(self) -> Command:
"""Return install command."""
return Command()

View file

@ -6,22 +6,8 @@ from pathlib import Path
class Project:
"""Parent class for any type of project."""
def __init__(self, file: Path) -> None:
def __init__(self, file_path: str) -> None:
"""Set file, root & name."""
self.raw = file
self.file = self.raw.resolve()
self.file: Path = Path(file_path).resolve()
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"""\
raw = {self.raw}
file = {self.file}
root = {self.root}
name = {self.name}
"""

View file

@ -2,18 +2,22 @@
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from pathlib import Path
from sphinx.cmd.build import build_main
from rwx.fs import wipe
from rwx.prj import Project
if TYPE_CHECKING:
from pathlib import Path
class SphinxProject(Project):
"""Child class for a project based on Sphinx."""
def __init__(self, file_path: str) -> None:
"""Call the parent constructor."""
super().__init__(file_path)
def build(self) -> None:
"""Build the project."""
output_root: Path = self.root / "out"
@ -27,9 +31,9 @@ class SphinxProject(Project):
"-D",
f"project={self.name}",
"-D",
"master_doc=index",
"master_doc={}".format("index"),
"-D",
"html_theme=sphinx_rtd_theme",
"html_theme={}".format("sphinx_rtd_theme"),
"-c",
str(self.root),
# "-C",

View file

@ -5,26 +5,6 @@ import subprocess
from rwx import txt
class Command:
"""Command to run."""
def __init__(self, *arguments: str | tuple[str, ...]) -> None:
"""Set raw & flat arguments."""
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"""\
raw = {self.raw}
flat = {self.flat}
"""
def get_tuples_args(*items: str | tuple[str, ...]) -> list[str]:
"""Turn arguments tuples into an arguments list."""
args: list[str] = []