python: Simplify with str.removeprefix, str.removesuffix.

These are available in Python ≥ 3.9.
https://docs.python.org/3/library/stdtypes.html#str.removeprefix

Signed-off-by: Anders Kaseorg <anders@zulip.com>
(cherry picked from commit 91ade25ba3)
This commit is contained in:
Anders Kaseorg
2024-09-03 10:42:14 -07:00
committed by Tim Abbott
parent 61e6723a51
commit 680f318bc0
42 changed files with 79 additions and 92 deletions

View File

@@ -58,7 +58,8 @@ def list_supervisor_processes(
for filter_name in filter_names:
# zulip-tornado:* matches zulip-tornado:9800 and zulip-tornado
if filter_name.endswith(":*") and (
name.startswith(filter_name[:-1]) or name == filter_name[:-2]
name.startswith(filter_name.removesuffix("*"))
or name == filter_name.removesuffix(":*")
):
match = True
break