disable unused if clause

This commit is contained in:
2021-12-23 12:37:02 +01:00
parent 5df9c0de93
commit 67b72d935d

View File

@@ -124,40 +124,39 @@ def index():
@app.route("/", methods=["POST"]) @app.route("/", methods=["POST"])
def index_post(): def index_post():
"""Index page with POST request""" """Index page with POST request"""
if request.method == "POST": if request.form["action"] == "message":
if request.form["action"] == "message": input_message = request.form["message"]
input_message = request.form["message"] with open(
with open( get_messagefile(app.config.get("MAIL_USER")), "w", encoding="utf-8"
get_messagefile(app.config.get("MAIL_USER")), "w", encoding="utf-8" ) as messagefile:
) as messagefile: messagefile.write(str(input_message))
messagefile.write(str(input_message)) result = "Success: The autoreply message has been updated!"
result = "Success: The autoreply message has been updated!"
if request.form["action"] == "qmail": if request.form["action"] == "qmail":
# define whether to set a comment # define whether to set a comment
if request.form["status"] == "on": if request.form["status"] == "on":
state_current = get_maildropline( state_current = get_maildropline(
app.config.get("MAIL_USER"), active=False app.config.get("MAIL_USER"), active=False
) )
state_desired = get_maildropline(app.config.get("MAIL_USER")) state_desired = get_maildropline(app.config.get("MAIL_USER"))
else: else:
state_current = get_maildropline(app.config.get("MAIL_USER")) state_current = get_maildropline(app.config.get("MAIL_USER"))
state_desired = get_maildropline( state_desired = get_maildropline(
app.config.get("MAIL_USER"), active=False 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( result = f"Success: the autoreply is now {request.form['status']}."
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']}."
try: try:
return render_template("result.html", result=result) return render_template("result.html", result=result)