Added tomli/tomllib module dependency

This commit is contained in:
jeancf 2022-11-29 11:11:47 +01:00
parent 07e28948db
commit d1b23e5c0d

View File

@ -100,17 +100,21 @@ def build_config(args):
# Load config file if it was provided
toml_file = args['f']
if toml_file is not None:
import tomli
try: # Included starting with python 3.11
import tomllib
except ModuleNotFoundError:
# for python < 3.11, tomli module must be installed
import tomli as tomllib
loaded_toml
# Load toml file
try:
with open(toml_file, 'rb') as config_file:
loaded_toml = tomli.load(config_file)
loaded_toml = tomllib.load(config_file)
except FileNotFoundError:
print('config file not found')
exit(-1)
except tomli.TOMLDecodeError:
except tomllib.TOMLDecodeError:
print('Malformed config file')
exit(-1)