confini

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

commit 2e116935021584bc8531d97d738344b1c5572566
parent 5682bdb6b58d3eb09184155e6dba7414116b7e4a
Author: nolash <dev@holbrook.no>
Date:   Wed,  2 Dec 2020 08:48:56 +0100

Add truncate value output on dump

Diffstat:
MCHANGELOG | 3+++
Aconfini/runnable/dump.py | 34++++++++++++++++++++++++++++++++++
Dscripts/parse.py | 19-------------------
Msetup.py | 6++----
4 files changed, 39 insertions(+), 23 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG @@ -1,3 +1,6 @@ +0.3.2 + - Move config dump script to entry_point.console_scripts + - Add truncate value option to dump tool 0.3.1 - Remove None string literal on empty values in dump 0.3.0 diff --git a/confini/runnable/dump.py b/confini/runnable/dump.py @@ -0,0 +1,34 @@ +# standard imports +import sys +import logging +import argparse + +# local imports +from confini import Config + +logging.basicConfig(level=logging.WARNING) +logg = logging.getLogger() + + +argparser = argparse.ArgumentParser() +argparser.add_argument('-z', action='store_true', help='Truncate values in output') +argparser.add_argument('-v', action='store_true', help='Be verbose') +argparser.add_argument('config_dir', type=str, help='Configuation directory to parse') +args = argparser.parse_args() + +if args.v: + logg.setLevel(logging.DEBUG) + + +def main(): + c = Config(args.config_dir) + c.process() + for k in c.store.keys(): + v = c.get(k) + if args.z or v == None: + v = '' + print('{}={}'.format(k, v)) + + +if __name__ == "__main__": + main() diff --git a/scripts/parse.py b/scripts/parse.py @@ -1,19 +0,0 @@ -import sys -import logging - -from confini import Config - -#logging.basicConfig(level=logging.DEBUG) -logg = logging.getLogger() - -if __name__ == "__main__": - if len(sys.argv) < 2: - sys.stderr.write('usage: config.py <config_dir>') - sys.exit(1) - c = Config(sys.argv[1]) - c.process() - for k in c.store.keys(): - v = c.get(k) - if v == None: - v = '' - print('{}={}'.format(k, v)) diff --git a/setup.py b/setup.py @@ -6,7 +6,7 @@ f.close() setup( name='confini', - version='0.3.1', + version='0.3.2', description='Parse, verify and merge all ini files in a single directory', author='Louis Holbrook', author_email='dev@holbrook.no', @@ -18,9 +18,7 @@ setup( ], packages=[ 'confini', + 'confini.runnable', ], - scripts = [ - 'scripts/parse.py', - ], url='https://gitlab.com/nolash/python-confini', )