from __future__ import annotations

import os

class Path():

    def __init__(self, *paths: str | Path):
        self._absolute_path: str = ""
        for path in paths:
            self._absolute_path = os.path.join(self._absolute_path, path._absolute_path if isinstance(path, Path) else path)
        self._name: str = os.path.basename(self._absolute_path)
        self._dirpath: str = os.path.dirname(self._absolute_path)
    
    def __str__(self) -> str:
          return self._name

    def get_dirpath(self):
        return self._dirpath

    def get_absolute_path(self):
        return self._absolute_path
    
    def get_name(self):
        if not self.exist():
            return None
        return self._name

    def exist(self) -> bool:
        return os.path.exists(self.get_absolute_path())
    
    def get_dirs(self) -> list[Path]:
        dirs: list[Path] = []
        for element in os.listdir(self.get_absolute_path()):
            path: Path = Path(self._absolute_path, element)
            if (os.path.isdir(path.get_absolute_path())):
                dirs.append(path)
        return dirs

    def get_files(self) -> list[Path]:
        files: list[Path] = []
        for element in os.listdir(self.get_absolute_path()):
            path: Path = Path(self._absolute_path, element)
            if (os.path.isfile(path.get_absolute_path())):
                files.append(path)
        return files