Refactor configuration handling in MeshCoreBot

- Removed custom _DuplicateAwareConfigParser in favor of standard configparser.ConfigParser.
- Simplified configuration loading process while maintaining existing functionality.
This commit is contained in:
agessaman
2026-02-22 20:43:43 -08:00
parent 870e57b4c9
commit 94418bebee
+1 -17
View File
@@ -43,22 +43,6 @@ from .transmission_tracker import TransmissionTracker
from .utils import resolve_path
class _DuplicateAwareConfigParser(configparser.ConfigParser):
"""ConfigParser that allows duplicate options (last value wins) and logs ERROR when seen."""
def __init__(self, *args, **kwargs):
kwargs['strict'] = False
super().__init__(*args, **kwargs)
def _handle_option(self, st, line, fpname):
if st.optname in st.options:
logging.getLogger(__name__).error(
"Duplicate option in config file: section [%s], option '%s' (file %s, line %s). Using last value.",
st.sectname, st.optname, fpname, getattr(st, 'lineno', '?'),
)
st.options[st.optname] = st.optvalue
class MeshCoreBot:
"""MeshCore Bot using official meshcore package.
@@ -68,7 +52,7 @@ class MeshCoreBot:
def __init__(self, config_file: str = "config.ini"):
self.config_file = config_file
self.config = _DuplicateAwareConfigParser()
self.config = configparser.ConfigParser()
self.load_config()
# Setup logging