Skip to content

Commit

Permalink
allow local config override
Browse files Browse the repository at this point in the history
  • Loading branch information
wuan committed Feb 5, 2025
1 parent e776db2 commit ab37754
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions blitzortung/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@
"""

try:
import configparser
except ImportError:
import ConfigParser as configparser
from typing import Optional
import os

import configparser
#import ConfigParser as configparser

from injector import Module, singleton, inject, provider

Expand Down Expand Up @@ -69,6 +70,15 @@ class ConfigModule(Module):
@singleton
@provider
def provide_config_parser(self) -> configparser.ConfigParser:
config_file_path = self.find_config_file_path()

config_parser = configparser.ConfigParser()
config_parser.read('/etc/blitzortung.conf')
return config_parser

def find_config_file_path(self) -> Optional[str]:
config_file_name = "blitzortung.conf"
for config_dir_name in [".", "/etc/"]:
config_file_path = os.path.join(config_dir_name, config_file_name)
if os.path.exists(config_file_path):
return config_file_path

0 comments on commit ab37754

Please sign in to comment.