This commit is contained in:
Marc Beninca 2024-09-14 23:40:39 +02:00
parent 6f9ba7f8f7
commit 0ad5cc9701
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
3 changed files with 23 additions and 21 deletions

View file

@ -1,30 +1,15 @@
"""Control Operating Systems.""" """Control Operating Systems."""
from __future__ import annotations
from abc import ABC, abstractmethod
from os import sep from os import sep
from pathlib import Path from pathlib import Path
from .abstract import OS
from .debian import Debian from .debian import Debian
class OS(ABC): def from_path(path: Path) -> OS:
"""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."""
@staticmethod
def from_path(path: Path) -> OS:
"""Initialize from an already existing path.""" """Initialize from an already existing path."""
return Debian(path) return Debian(path)
os = OS.from_path(Path(sep)) up = from_path(Path(sep))

17
rwx/os/abstract.py Normal file
View file

@ -0,0 +1,17 @@
"""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."""

View file

@ -1,6 +1,6 @@
"""Debian operating system.""" """Debian operating system."""
from . import OS from .abstract import OS
class Debian(OS): class Debian(OS):