From d1b23e5c0d29296b878f083cc8aba6eb77ddafac Mon Sep 17 00:00:00 2001 From: jeancf Date: Tue, 29 Nov 2022 11:11:47 +0100 Subject: [PATCH] Added tomli/tomllib module dependency --- twoot.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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)