diff --git a/twoot.py b/twoot.py index 0f77573..7b8db5c 100755 --- a/twoot.py +++ b/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)