mirror of
https://gitlab.com/jeancf/twoot.git
synced 2025-02-22 08:12:15 +00:00
Added tomli/tomllib module dependency
This commit is contained in:
parent
07e28948db
commit
d1b23e5c0d
10
twoot.py
10
twoot.py
|
@ -100,17 +100,21 @@ def build_config(args):
|
||||||
# Load config file if it was provided
|
# Load config file if it was provided
|
||||||
toml_file = args['f']
|
toml_file = args['f']
|
||||||
if toml_file is not None:
|
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
|
loaded_toml
|
||||||
|
|
||||||
# Load toml file
|
# Load toml file
|
||||||
try:
|
try:
|
||||||
with open(toml_file, 'rb') as config_file:
|
with open(toml_file, 'rb') as config_file:
|
||||||
loaded_toml = tomli.load(config_file)
|
loaded_toml = tomllib.load(config_file)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print('config file not found')
|
print('config file not found')
|
||||||
exit(-1)
|
exit(-1)
|
||||||
except tomli.TOMLDecodeError:
|
except tomllib.TOMLDecodeError:
|
||||||
print('Malformed config file')
|
print('Malformed config file')
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user