From 0ad5cc97018d13482820304d62494414a1eee995 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sat, 14 Sep 2024 23:40:39 +0200 Subject: [PATCH] cyclic --- rwx/os/__init__.py | 25 +++++-------------------- rwx/os/abstract.py | 17 +++++++++++++++++ rwx/os/debian.py | 2 +- 3 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 rwx/os/abstract.py diff --git a/rwx/os/__init__.py b/rwx/os/__init__.py index 3dfa782..75a0bc9 100644 --- a/rwx/os/__init__.py +++ b/rwx/os/__init__.py @@ -1,30 +1,15 @@ """Control Operating Systems.""" -from __future__ import annotations - -from abc import ABC, abstractmethod from os import sep from pathlib import Path +from .abstract import OS from .debian import Debian -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.""" - - @staticmethod - def from_path(path: Path) -> OS: - """Initialize from an already existing path.""" - return Debian(path) +def from_path(path: Path) -> OS: + """Initialize from an already existing path.""" + return Debian(path) -os = OS.from_path(Path(sep)) +up = from_path(Path(sep)) diff --git a/rwx/os/abstract.py b/rwx/os/abstract.py new file mode 100644 index 0000000..2d86f7e --- /dev/null +++ b/rwx/os/abstract.py @@ -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.""" diff --git a/rwx/os/debian.py b/rwx/os/debian.py index dbaaabb..98c8928 100644 --- a/rwx/os/debian.py +++ b/rwx/os/debian.py @@ -1,6 +1,6 @@ """Debian operating system.""" -from . import OS +from .abstract import OS class Debian(OS):