Add config parser functionality
Signed-off-by: Václav Valíček <valicek1994@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import os.path
|
||||
from repo_cloner.lib.dir_not_found_error import DirNotFoundError
|
||||
from repo_cloner.lib.config_file_not_found_error import ConfigFileNotFoundError
|
||||
from repo_cloner.lib.cloner_config import ClonerConfig, ClonerConfigParser
|
||||
|
||||
|
||||
class RepoDirStructure():
|
||||
@@ -8,12 +9,14 @@ class RepoDirStructure():
|
||||
_conf_dir: str = ""
|
||||
_cache_dir: str = ""
|
||||
_repos_dir: str = ""
|
||||
_config = None
|
||||
|
||||
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")
|
||||
self._config = None
|
||||
|
||||
@property
|
||||
def __config_filename(self) -> str:
|
||||
@@ -75,3 +78,15 @@ class RepoDirStructure():
|
||||
if not os.path.exists(self.__config_filename):
|
||||
raise ConfigFileNotFoundError(self.__config_filename)
|
||||
return True
|
||||
|
||||
@property
|
||||
def config_file(self):
|
||||
return self.__config_filename
|
||||
|
||||
@property
|
||||
def config(self) -> ClonerConfig:
|
||||
self.has_config
|
||||
if not self._config:
|
||||
parser = ClonerConfigParser(self.__config_filename)
|
||||
self._config = parser.config
|
||||
return self._config
|
||||
|
||||
Reference in New Issue
Block a user