confini

Parse and merge multiple ini files in python3
git clone git://git.defalsify.org/python-confini.git
Log | Files | Refs | README | LICENSE

commit 6736f3ccd24acff03234998af1c1ed9e021fe60c
parent c7a01007b88ec36dcdec724bfb7c4f6961ad4028
Author: nolash <dev@holbrook.no>
Date:   Tue, 13 Jul 2021 11:19:06 +0200

Remove update logline for unchanged values

Diffstat:
MCHANGELOG | 5++++-
Mconfini/config.py | 15++++++++++-----
Msetup.py | 2+-
3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,6 +1,9 @@ -0.3.5 +0.4.0 + - Enable multiple config override directories +0.3.6 - Fix logging bug in 0.3.4 update - Add key exist guard in add method +0.3.5-unreleased 0.3.4 - Fix bug in 0.3.3 update 0.3.3 diff --git a/confini/config.py b/confini/config.py @@ -44,11 +44,13 @@ class Config: def add(self, value, constant_name, exists_ok=False): - if self.store.get(constant_name) != None: + value_stored = self.store.get(constant_name) + if not self.is_as_none(value_stored): if not exists_ok: raise AttributeError('config key {} already exists'.format(constant_name)) else: - logg.debug('overwriting key {}'.format(constant_name)) + if value_stored != value: + logg.debug('updating key {}'.format(constant_name)) self.store[constant_name] = value @@ -156,7 +158,7 @@ class Config: for so in self.parser.options(s): k = self.to_constant_name(so, s) v = self.parser.get(s, so) - logg.debug('config set: {} -> {}'.format(k, v)) + logg.debug('default config set {}'.format(k)) self.add(v, k, exists_ok=True) self.set_dir(k, self.dirs[i]) else: @@ -171,7 +173,7 @@ class Config: v = local_parser.get(s, so) logg.debug('checking {} {} {}'.format(k, s, so)) if not self.is_as_none(v): - logg.debug('multi config file override: {} -> {}'.format(k, v)) + logg.debug('multi config file overrides {}'.format(k)) self.add(v, k, exists_ok=True) self.set_dir(k, self.dirs[i]) c += 1 @@ -253,7 +255,10 @@ class Config: @classmethod def is_as_none(cls, v): - return isinstance(v, str) and v == '' + if isinstance(v, str) and v == '': + return True + if v == None: + return True def config_from_environment(): diff --git a/setup.py b/setup.py @@ -6,7 +6,7 @@ f.close() setup( name='confini', - version='0.4.0a1", + version='0.4.0a2", description='Parse, verify and merge all ini files in a single directory', author='Louis Holbrook', author_email='dev@holbrook.no',