code formatting (black)

This commit is contained in:
adam j hartz 2024-06-26 12:44:31 -04:00
commit a90afa0587
Signed by: hz
GPG key ID: B63A0A59F5C82493
6 changed files with 31 additions and 26 deletions

View file

@ -1835,9 +1835,11 @@ def get_last_action_data(context, question_name):
"last_submit" if last_action == "submit" else "last_check", {}
)
last_cached_responses = last_problem_state.get(
"submit_cached_responses"
if last_action == "submit"
else "check_cached_responses",
(
"submit_cached_responses"
if last_action == "submit"
else "check_cached_responses"
),
{},
)
@ -1889,9 +1891,9 @@ def render_question(elt, context, wrap=True):
args,
name,
None,
last_log=context[_n("last_log")]
if last_action in {"submit", "revert"}
else {},
last_log=(
context[_n("last_log")] if last_action in {"submit", "revert"} else {}
),
)
+ "</span>"
)

View file

@ -542,9 +542,11 @@ def render_html_upload(last_log, **info):
"init": str(init_code),
"safeinit": html.escape(init_code or ""),
"b64init": b64encode(make_initial_display(info).encode()).decode(),
"dl": (' download="%s"' % info["csq_skeleton_name"])
if "csq_skeleton_name" in info
else "download",
"dl": (
(' download="%s"' % info["csq_skeleton_name"])
if "csq_skeleton_name" in info
else "download"
),
}
out = ""
if info.get("csq_show_skeleton", True):

View file

@ -54,12 +54,14 @@ def render_html(last_log, **info):
"init": str(init),
"safeinit": (init or "").replace("<", "&lt;"),
"b64init": base64.b64encode(make_initial_display(info).encode()).decode(),
"dl": (' download="%s"' % info["csq_skeleton_name"])
if "csq_skeleton_name" in info
else "download",
"dl2": (' download="%s"' % fname)
if "csq_skeleton_name" in info
else "download",
"dl": (
(' download="%s"' % info["csq_skeleton_name"])
if "csq_skeleton_name" in info
else "download"
),
"dl2": (
(' download="%s"' % fname) if "csq_skeleton_name" in info else "download"
),
}
out = ""
if last_log.get(name, None) is not None:

View file

@ -455,9 +455,8 @@ def display_page(context):
if context["cs_dark_mode_invert_videos"]
else "video.catsoop-darkmode-invert"
)
context[
"cs_dark_mode_javascript"
] = """
context["cs_dark_mode_javascript"] = (
"""
document.addEventListener("DOMContentLoaded", function(event) {
if (DarkReader.isEnabled()) {
var invertfilter = 'invert(100%%) hue-rotate(180deg)' +
@ -469,9 +468,11 @@ def display_page(context):
inverter.innerText = '%s, %s {filter: ' + invertfilter + ';}\\n\\n'
document.head.appendChild(inverter);
}
});""" % (
imgselector,
videoselector,
});"""
% (
imgselector,
videoselector,
)
)
out = (

View file

@ -83,9 +83,9 @@ def yesno(question, default="Y"):
question,
default,
lambda x: x.lower(),
lambda x: None
if x in {"y", "n", "yes", "no"}
else WARNING("Please answer Yes or No"),
lambda x: (
None if x in {"y", "n", "yes", "no"} else WARNING("Please answer Yes or No")
),
)
if res.startswith("y"):
return True

View file

@ -290,7 +290,6 @@ def parse_header(line):
class MiniFieldStorage:
"""Like FieldStorage, for use when no file uploads are possible."""
# Dummy attributes
@ -315,7 +314,6 @@ class MiniFieldStorage:
class FieldStorage:
"""Store a sequence of fields, reading multipart/form-data.
This class provides naming, typing, files stored on disk, and