-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase_config.py
37 lines (28 loc) · 991 Bytes
/
base_config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from confuse.core import Configuration
import yaml
import os
from enum import Enum, auto
from dataclasses import dataclass
from typing import List, Dict
import pytest
import confuse
# from pytest import fixture
from pytest_cases import fixture
class BackupConfig:
def __init__(self, config_file) -> None:
self.config = self._get_base_config(config_file)
self.lxd = self.config.get()
self._set_backup_jobs()
pass
def _get_base_config(self, config_file):
# use confuse to parse config file
config = confuse.Configuration("lxdbackup", __name__)
config.set_file(config_file) # set the specific config file
return config
def _set_backup_jobs(self):
cfg = self.config.get()
self.backup_jobs = cfg["lxd"]["backup"]["jobs"]
def get_backup_jobs(self):
return self.backup_jobs
def get_job_containers(self, job) -> Dict:
return self.config["lxd"]["backup"][job]["containers"]