@@ -1,5 +1,6 @@
|
||||
import os.path
|
||||
from repo_cloner.lib.dir_not_found_error import DirNotFoundError
|
||||
from repo_cloner.lib.config_file_not_found_error import ConfigFileNotFoundError
|
||||
|
||||
|
||||
class RepoDirStructure():
|
||||
@@ -15,25 +16,29 @@ class RepoDirStructure():
|
||||
self._repos_dir = os.path.join(self._base_dir, "repos")
|
||||
|
||||
@property
|
||||
def base_dir_exists(self):
|
||||
def __config_filename(self) -> str:
|
||||
return os.path.join(self.conf_dir, "cloner.cfg")
|
||||
|
||||
@property
|
||||
def base_dir_exists(self) -> bool:
|
||||
if not os.path.isdir(self._base_dir):
|
||||
raise DirNotFoundError(self._base_dir)
|
||||
return True
|
||||
|
||||
@property
|
||||
def conf_dir_exists(self):
|
||||
def conf_dir_exists(self) -> bool:
|
||||
if not os.path.isdir(self._conf_dir):
|
||||
raise DirNotFoundError(self._conf_dir)
|
||||
return True
|
||||
|
||||
@property
|
||||
def cache_dir_exists(self):
|
||||
def cache_dir_exists(self) -> bool:
|
||||
if not os.path.isdir(self._cache_dir):
|
||||
raise DirNotFoundError(self._cache_dir)
|
||||
return True
|
||||
|
||||
@property
|
||||
def repos_dir_exists(self):
|
||||
def repos_dir_exists(self) -> bool:
|
||||
if not os.path.isdir(self._repos_dir):
|
||||
raise DirNotFoundError(self._repos_dir)
|
||||
return True
|
||||
@@ -64,3 +69,9 @@ class RepoDirStructure():
|
||||
@property
|
||||
def repos_dir(self) -> str:
|
||||
return self._repos_dir
|
||||
|
||||
@property
|
||||
def has_config(self) -> bool:
|
||||
if not os.path.exists(self.__config_filename):
|
||||
raise ConfigFileNotFoundError(self.__config_filename)
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user