mikes-backup-rotator/domain/config/Config.py

44 lines
813 B
Python
Raw Normal View History

from domain.config.ConfigFile import ConfigFile
from domain.config.Scanner import Scanner
from domain.Logger import Logger
from pathlib import Path
class Config:
def __init__(self, logger: Logger, config_files_paths: [Path]):
2023-03-27 19:59:45 -07:00
self.__logger = logger
self.__config_files_paths: [Path] = config_files_paths
2024-06-09 09:41:00 -07:00
self.__configs = {}
self.__scanner = Scanner(
logger=self.__logger
)
self._consume_configs()
2024-06-09 09:41:00 -07:00
def _consume_configs(self):
2024-06-09 09:41:00 -07:00
config_paths = self.__scanner.gather_valid_config_paths(
paths=self.__config_files_paths
)
for config_path in config_paths:
config = ConfigFile(
logger=self.__logger,
path=config_path
)
2023-03-27 19:59:45 -07:00
self.__configs[config.key] = config
@property
def config_files(self) -> [ConfigFile]:
return self.__configs.values()