Skip to content

Commit

Permalink
[config] Live reload of setup.cfg
Browse files Browse the repository at this point in the history
This code allows to reload the setup.cfg everytime
the method `get_conf` in the class `Config` is
called.

Signed-off-by: Valerio Cosentino <[email protected]>
  • Loading branch information
valeriocos committed Sep 17, 2019
1 parent 52c722f commit b077467
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sirmordred/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import configparser
import logging
from threading import Lock

from sirmordred._version import __version__

Expand All @@ -41,6 +42,8 @@
class Config():
"""Class aimed to manage sirmordred configuration"""

config_lock = Lock()

def __init__(self, conf_file, conf_list=[]):
"""Initialize object.
Expand Down Expand Up @@ -654,8 +657,11 @@ def create_config_file(cls, file_path):
parser.write(f)

def get_conf(self):
# TODO: Return a deepcopy to avoid uncontrolled changes in config?
return self.conf
"""Reload configuration files"""

with self.config_lock:
self.__read_conf_files()
return self.conf

def set_param(self, section, param, value):
""" Change a param in the config """
Expand Down

0 comments on commit b077467

Please sign in to comment.