Fixed loading config

This commit is contained in:
jeancf 2022-11-17 23:30:22 +01:00
parent d336711514
commit 4a30746f25

View File

@ -346,7 +346,8 @@ def main(argv):
} }
# Default empty toml # Default empty toml
toml = {'config': {}, 'options': options} # toml = {'config': {}, 'options': options}
toml = {}
# Load config file if it was provided # Load config file if it was provided
toml_file = args['f'] toml_file = args['f']
@ -354,7 +355,7 @@ def main(argv):
import tomli import tomli
try: try:
with open(toml_file, 'rb') as config_file: with open(toml_file, 'rb') as config_file:
toml = tomli.read(config_file) toml = tomli.load(config_file)
except FileNotFoundError: except FileNotFoundError:
print('config file not found') print('config file not found')
exit(-1) exit(-1)
@ -362,6 +363,8 @@ def main(argv):
print('Malformed config file') print('Malformed config file')
exit(-1) exit(-1)
print(toml)
# Override config file parameter values with command-line values if provided # Override config file parameter values with command-line values if provided
if args['t'] is not None: if args['t'] is not None:
toml['config']['twitter_account'] = args['t'] toml['config']['twitter_account'] = args['t']