From 5693bc6265846dbc11ce4ae8c1b0a8a8080a966f Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 14 Nov 2021 07:58:40 +0000 Subject: [PATCH] Code formatting --- matcher/error_mail.py | 30 +++++++++++++++++++----------- matcher/nominatim.py | 1 + 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/matcher/error_mail.py b/matcher/error_mail.py index 45ad845..a7a6563 100644 --- a/matcher/error_mail.py +++ b/matcher/error_mail.py @@ -3,13 +3,16 @@ from logging.handlers import SMTPHandler from logging import Formatter from flask import request -PROJECT = 'osm-wikidata' +PROJECT = "osm-wikidata" + class MatcherSMTPHandler(SMTPHandler): def getSubject(self, record): # noqa: N802 - return (f'{PROJECT} error: {record.exc_info[0].__name__}' - if (record.exc_info and record.exc_info[0]) - else f'{PROJECT} error: {record.pathname}:{record.lineno:d}') + return ( + f"{PROJECT} error: {record.exc_info[0].__name__}" + if (record.exc_info and record.exc_info[0]) + else f"{PROJECT} error: {record.pathname}:{record.lineno:d}" + ) class RequestFormatter(Formatter): @@ -19,9 +22,10 @@ class RequestFormatter(Formatter): def setup_error_mail(app): - if not app.config.get('ERROR_MAIL'): + if not app.config.get("ERROR_MAIL"): return - formatter = RequestFormatter(''' + formatter = RequestFormatter( + """ Message type: {levelname} Location: {pathname:s}:{lineno:d} Module: {module:s} @@ -33,12 +37,16 @@ def setup_error_mail(app): Message: {message:s} - ''', style='{') + """, + style="{", + ) - mail_handler = MatcherSMTPHandler(app.config['SMTP_HOST'], - app.config['MAIL_FROM'], - app.config['ADMINS'], - app.name + ' error') + mail_handler = MatcherSMTPHandler( + app.config["SMTP_HOST"], + app.config["MAIL_FROM"], + app.config["ADMINS"], + app.name + " error", + ) mail_handler.setFormatter(formatter) mail_handler.setLevel(logging.ERROR) diff --git a/matcher/nominatim.py b/matcher/nominatim.py index 137a05d..5e70793 100644 --- a/matcher/nominatim.py +++ b/matcher/nominatim.py @@ -101,6 +101,7 @@ def get_hit_name(hit): n2 = address_values[1] return f"{n1}, {n2}, {country}" + def get_hit_label(hit): tags = hit["extratags"] designation = tags.get("designation")