handle no redirects in config

This commit is contained in:
Tomáš Mládek 2019-11-07 16:29:29 +01:00
parent 409ffc4b7e
commit 39cbfb851a

View file

@ -11,7 +11,7 @@ import subprocess
import sys import sys
import tempfile import tempfile
import unicodedata import unicodedata
from configparser import ConfigParser from configparser import ConfigParser, NoSectionError
from datetime import datetime, timedelta from datetime import datetime, timedelta
from glob import glob from glob import glob
from operator import itemgetter from operator import itemgetter
@ -796,10 +796,15 @@ if __name__ == '__main__':
logging.warning("Didn't find `initial.txt`, continuing without markov blabbering!") logging.warning("Didn't find `initial.txt`, continuing without markov blabbering!")
markov = None markov = None
try:
redirects = config.items('redirects')
except NoSectionError:
redirects = {}
delojza = DelojzaBot(config.get('delojza', 'tg_api_key'), delojza = DelojzaBot(config.get('delojza', 'tg_api_key'),
config.get('delojza', 'OUT_DIR', fallback=os.path.join(_DIR_, "out")), config.get('delojza', 'OUT_DIR', fallback=os.path.join(_DIR_, "out")),
tmp_dir=config.get('delojza', 'tmp_dir', fallback=tempfile.gettempdir()), 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), protected_password=config.get('delojza', 'protected_password', fallback=None),
acoustid_key=config.get('delojza', 'acoustid_api_key', fallback=None), acoustid_key=config.get('delojza', 'acoustid_api_key', fallback=None),
tumblr_name=config.get('tumblr', 'blog_name', fallback=None), tumblr_name=config.get('tumblr', 'blog_name', fallback=None),