45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
import os.path
|
|
from repo_cloner.lib.dir_not_found_error import DirNotFoundError
|
|
|
|
|
|
class RepoDirStructure():
|
|
_base_dir: str = ""
|
|
_conf_dir: str = ""
|
|
_cache_dir: str = ""
|
|
_repos_dir: str = ""
|
|
|
|
def __init__(self, base_dir: str):
|
|
self._base_dir = base_dir
|
|
self._conf_dir = os.path.join(self._base_dir, "config")
|
|
self._cache_dir = os.path.join(self._base_dir, "cache")
|
|
self._repos_dir = os.path.join(self._base_dir, "repos")
|
|
|
|
@property
|
|
def exists(self) -> bool:
|
|
if not os.path.isdir(self._base_dir):
|
|
raise DirNotFoundError(self._base_dir)
|
|
if not os.path.isdir(self._conf_dir):
|
|
raise DirNotFoundError(self._conf_dir)
|
|
if not os.path.isdir(self._cache_dir):
|
|
raise DirNotFoundError(self._cache_dir)
|
|
if not os.path.isdir(self._repos_dir):
|
|
raise DirNotFoundError(self._repos_dir)
|
|
|
|
return True
|
|
|
|
@property
|
|
def base_dir(self) -> str:
|
|
return self._base_dir
|
|
|
|
@property
|
|
def cache_dir(self) -> str:
|
|
return self._cache_dir
|
|
|
|
@property
|
|
def conf_dir(self) -> str:
|
|
return self._conf_dir
|
|
|
|
@property
|
|
def repos_dir(self) -> str:
|
|
return self._repos_dir
|