From b4144c3f145b5c4bac0b8cdb86dfd665f3bc3714 Mon Sep 17 00:00:00 2001 From: Richard Springer Date: Fri, 12 Jan 2024 15:28:06 +0100 Subject: [PATCH] lowercase & underscore names --- dotini/__init__.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/dotini/__init__.py b/dotini/__init__.py index 6aa7326..5e79588 100644 --- a/dotini/__init__.py +++ b/dotini/__init__.py @@ -33,13 +33,14 @@ import configparser -__copyright__ = 'Copyright (c) 2018 James Thomas Kirkpatrick IV' -__license__ = 'MIT' -__version__ = '0.0.1' +__copyright__ = "Copyright (c) 2018 James Thomas Kirkpatrick IV" +__license__ = "MIT" +__version__ = "0.0.1" class _ConfigSection(object): """Hold settings for a section of the configuration file.""" + def __getattr__(self, attr): if attr in self.__dict__: return self.__dict__[attr] @@ -61,11 +62,12 @@ def read(config_file): dotini = _ConfigSection() for section in config.sections(): - settings = _ConfigSection() for key, value in config.items(section): - setattr(settings, key, value) + setattr( + settings, key.lower().replace(" ", "_"), value.lower().replace(" ", "_") + ) - setattr(dotini, section, settings) + setattr(dotini, section.lower().replace(" ", "_"), settings) return dotini