diff --git a/CHANGELOG.md b/CHANGELOG.md index 136ce05..887cd81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,26 @@ # Changelog +**11 DEC 2022** + +VERSION 3.1 HOTFIX + +* Added missing `default.toml` file +* Corrected a bug that could cause an infinity loop when log file is empty + +VERSION 3.0 brings some important changes and new features: + +* Only potentially breaking change: **If you are using a version of python < 3.11 you need to install the `tomli` module** +* Twoot can be configured with a config file in [TOML](https://toml.io/) format. Check `default.toml` for details +* Domain susbtitution can be configured in the config file to replace links to Twitter, Youtube and + Reddit domains with alternatives (e.g. [Nitter](https://github.com/zedeus/nitter/wiki/Instances), + [Invidious](https://redirect.invidious.io/) and [teddit](https://teddit.net/) respectively) +* A footer line can be specified in the config file that gets added to all toots (with e.g. tags) +* Added option to not add reference to "Original tweet" at the bottom of toots +* A password must be provided with `-p` on the command-line for the first run only. After that it is no longer required. +* The verbosity of logging messages can be set in the config file with `log_level=`. +* Config file option `log_days =` specifies how long to keep log messages in file. Older messages are deleted. + + **23 NOV 2022** VERSION 2.5 Added command-line option (`-l`) to remove redirection from links included in tweets. Obfuscated links are replaced by the URL that the resource is directly downloaded from. Also improved diff --git a/README.md b/README.md index 14d6cf0..c13886b 100644 --- a/README.md +++ b/README.md @@ -3,24 +3,9 @@ Twoot is a python script that mirrors tweets from a twitter account to a Mastodon account. It is simple to set-up on a local machine, configurable and feature-rich. -**UPDATE 11 DEC 2022** -VERSION 3.1 HOTFIX +**UPDATE 21 DEC 2022** VERSION 3.1.1 -* Added missing `default.toml` file -* Corrected a bug that could cause an infinity loop when log file is empty - -VERSION 3.0 brings some important changes and new features: - -* Only potentially breaking change: **If you are using a version of python < 3.11 you need to install the `tomli` module** -* Twoot can be configured with a config file in [TOML](https://toml.io/) format. Check `default.toml` for details -* Domain susbtitution can be configured in the config file to replace links to Twitter, Youtube and - Reddit domains with alternatives (e.g. [Nitter](https://github.com/zedeus/nitter/wiki/Instances), - [Invidious](https://redirect.invidious.io/) and [teddit](https://teddit.net/) respectively) -* A footer line can be specified in the config file that gets added to all toots (with e.g. tags) -* Added option to not add reference to "Original tweet" at the bottom of toots -* A password must be provided with `-p` on the command-line for the first run only. After that it is no longer required. -* The verbosity of logging messages can be set in the config file with `log_level=`. -* Config file option `log_days =` specifies how long to keep log messages in file. Older messages are deleted. +Modified code that made twoot incompatible with python versions < 3.10 > Previous updates can be found in CHANGELOG. diff --git a/twoot.py b/twoot.py index f23ae9d..7949735 100755 --- a/twoot.py +++ b/twoot.py @@ -634,24 +634,29 @@ def main(argv): datefmt='%Y-%m-%d %H:%M:%S', ) - # Set level of logging + # Set default level of logging log_level = logging.WARNING - match TOML['options']['log_level'].upper(): - case 'DEBUG': - log_level = logging.DEBUG - case 'INFO': - log_level = logging.INFO - case 'WARNING': - log_level = logging.WARNING - case 'ERROR': - log_level = logging.ERROR - case 'CRITICAL': - log_level = logging.CRITICAL - case 'OFF': - # Disable all logging - logging.disable(logging.CRITICAL) - case _: - logging.error('Invalid log_level %s in config file. Using WARNING.', str(TOML['options']['log_level'])) + + # log level as an uppercase string from config + ll_str = TOML['options']['log_level'].upper() + + if ll_str == "DEBUG": + log_level = logging.DEBUG + elif ll_str == "INFO": + log_level = logging.INFO + elif ll_str == "WARNING": + log_level = logging.WARNING + elif ll_str == "ERROR": + log_level = logging.ERROR + elif ll_str == "CRITICAL": + log_level == logging.CRITICAL + elif ll_str == "OFF": + # Disable all logging + logging.disable(logging.CRITICAL) + else: + logging.error('Invalid log_level %s in config file. Using WARNING.', str(TOML['options']['log_level'])) + + # Set desired level of logging logger = logging.getLogger() logger.setLevel(log_level)