X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=osm_pla%2Fconfig%2Fconfig.py;h=2fd7a8b648abd336b841fc0069ea976df9c35727;hb=41f7393ba4efde7c764569c6a357a124a6b17017;hp=114fc5f6f7a6b0cbc99b47697e60c5b788b367b0;hpb=2b0e2d72595a5e25bd8f785138416d12829fbd64;p=osm%2FPLA.git diff --git a/osm_pla/config/config.py b/osm_pla/config/config.py index 114fc5f..2fd7a8b 100644 --- a/osm_pla/config/config.py +++ b/osm_pla/config/config.py @@ -25,17 +25,17 @@ logger = logging.getLogger(__name__) class Config: - def __init__(self, config_file: str = ''): + def __init__(self, config_file: str = ""): self.conf = {} self._read_config_file(config_file) self._read_env() def _read_config_file(self, config_file): if not config_file: - path = 'pla.yaml' + path = "pla.yaml" config_file = pkg_resources.resource_filename(__name__, path) with open(config_file) as f: - self.conf = yaml.load(f) + self.conf = yaml.safe_load(f) def _read_env(self): for env in os.environ: @@ -45,10 +45,12 @@ class Config: if len(elements) < 3: logger.warning( "Environment variable %s=%s does not comply with required format. Section and/or field missing.", - env, os.getenv(env)) + env, + os.getenv(env), + ) continue section = elements[1] - field = '_'.join(elements[2:]) + field = "_".join(elements[2:]) value = os.getenv(env) if section not in self.conf: self.conf[section] = {}