From 39cbfb851aea15add5e90a6dd7c3488658a63eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Thu, 7 Nov 2019 16:29:29 +0100 Subject: [PATCH] handle no redirects in config --- delojza.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/delojza.py b/delojza.py index aac2830..6dc76b9 100755 --- a/delojza.py +++ b/delojza.py @@ -11,7 +11,7 @@ import subprocess import sys import tempfile import unicodedata -from configparser import ConfigParser +from configparser import ConfigParser, NoSectionError from datetime import datetime, timedelta from glob import glob from operator import itemgetter @@ -796,10 +796,15 @@ if __name__ == '__main__': logging.warning("Didn't find `initial.txt`, continuing without markov blabbering!") markov = None + try: + redirects = config.items('redirects') + except NoSectionError: + redirects = {} + delojza = DelojzaBot(config.get('delojza', 'tg_api_key'), config.get('delojza', 'OUT_DIR', fallback=os.path.join(_DIR_, "out")), tmp_dir=config.get('delojza', 'tmp_dir', fallback=tempfile.gettempdir()), - redirects=config.items('redirects'), + redirects=redirects, protected_password=config.get('delojza', 'protected_password', fallback=None), acoustid_key=config.get('delojza', 'acoustid_api_key', fallback=None), tumblr_name=config.get('tumblr', 'blog_name', fallback=None),