mirror of
https://gitlab.com/jeancf/twoot.git
synced 2025-02-20 07:12:05 +00:00
Added tomli/tomllib module dependency
This commit is contained in:
parent
07e28948db
commit
d1b23e5c0d
12
twoot.py
12
twoot.py
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user