From 615a02c161d850f81813f1b06e1f407beaa67ba7 Mon Sep 17 00:00:00 2001 From: Alexis Reynouard Date: Fri, 5 Aug 2022 09:39:55 +0200 Subject: [PATCH 1/2] Fix some bugs with boolean options --- icsv2ledger.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/icsv2ledger.py b/icsv2ledger.py index de4c6fb..ee87a91 100755 --- a/icsv2ledger.py +++ b/icsv2ledger.py @@ -178,6 +178,14 @@ def decode_escape_sequences(string): string), +def config_to_dict(config, key, defaults): + d = dict(config.items(key)) + for k,v in defaults.items(): + if type(v) is bool and type(d[k]) is not bool: + d[k] = config.getboolean(key, k) + return d + + def parse_args_and_config_file(): """ Read options from config file and CLI args 1. Reads hard coded DEFAULTS @@ -216,7 +224,7 @@ def parse_args_and_config_file(): .format(args.config_file, args.account), file=sys.stderr) sys.exit(1) - defaults = dict(config.items(args.account)) + defaults = config_to_dict(config, args.account, DEFAULTS) if defaults['src_account']: print('Section {0} in config file {1} contains command line only option src_account' From d9ffe403f6d086837920ed958cae54251f49af7c Mon Sep 17 00:00:00 2001 From: Alexis Reynouard Date: Fri, 5 Aug 2022 09:44:50 +0200 Subject: [PATCH 2/2] Fix some bugs with number parsing and decimal dot --- icsv2ledger.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icsv2ledger.py b/icsv2ledger.py index ee87a91..21cc151 100755 --- a/icsv2ledger.py +++ b/icsv2ledger.py @@ -647,7 +647,7 @@ def get_field_at_index(fields, index, csv_decimal_comma, ledger_decimal_comma): if csv_decimal_comma: decimal_separator = ',' else: - decimal_separator = '.' + decimal_separator = '\\.' re_non_number = '[^-0-9' + decimal_separator + ']'