From 67b72d935db283b892bf2b4de30ce298b5b093aa Mon Sep 17 00:00:00 2001 From: "max.mehl" Date: Thu, 23 Dec 2021 12:37:02 +0100 Subject: [PATCH] disable unused if clause --- autoreply_editor/main.py | 61 ++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/autoreply_editor/main.py b/autoreply_editor/main.py index 593cd99..06a676f 100644 --- a/autoreply_editor/main.py +++ b/autoreply_editor/main.py @@ -124,40 +124,39 @@ def index(): @app.route("/", methods=["POST"]) def index_post(): """Index page with POST request""" - if request.method == "POST": - if request.form["action"] == "message": - input_message = request.form["message"] - with open( - get_messagefile(app.config.get("MAIL_USER")), "w", encoding="utf-8" - ) as messagefile: - messagefile.write(str(input_message)) - result = "Success: The autoreply message has been updated!" + if request.form["action"] == "message": + input_message = request.form["message"] + with open( + get_messagefile(app.config.get("MAIL_USER")), "w", encoding="utf-8" + ) as messagefile: + messagefile.write(str(input_message)) + result = "Success: The autoreply message has been updated!" - if request.form["action"] == "qmail": - # define whether to set a comment - if request.form["status"] == "on": - state_current = get_maildropline( - app.config.get("MAIL_USER"), active=False - ) - state_desired = get_maildropline(app.config.get("MAIL_USER")) - else: - state_current = get_maildropline(app.config.get("MAIL_USER")) - state_desired = get_maildropline( - app.config.get("MAIL_USER"), active=False + if request.form["action"] == "qmail": + # define whether to set a comment + if request.form["status"] == "on": + state_current = get_maildropline( + app.config.get("MAIL_USER"), active=False + ) + state_desired = get_maildropline(app.config.get("MAIL_USER")) + else: + state_current = get_maildropline(app.config.get("MAIL_USER")) + state_desired = get_maildropline( + app.config.get("MAIL_USER"), active=False + ) + + with fileinput.FileInput( + get_qmailfile(app.config.get("MAIL_USER")), + inplace=True, + backup=".bak", + ) as qmailfile: + for line in qmailfile: + print( + line.replace(state_current, state_desired), + end="", ) - with fileinput.FileInput( - get_qmailfile(app.config.get("MAIL_USER")), - inplace=True, - backup=".bak", - ) as qmailfile: - for line in qmailfile: - print( - line.replace(state_current, state_desired), - end="", - ) - - result = f"Success: the autoreply is now {request.form['status']}." + result = f"Success: the autoreply is now {request.form['status']}." try: return render_template("result.html", result=result)