refactor: use .remove(prefix|suffix) str methods (py39)

This commit is contained in:
Thomas Waldmann 2025-11-03 22:35:37 +01:00
parent 8f40baa34b
commit 6157c4b968
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
2 changed files with 3 additions and 6 deletions

View file

@ -152,9 +152,9 @@ class DebugMixIn:
wanted = args.wanted
try:
if wanted.startswith("hex:"):
wanted = hex_to_bin(wanted[4:])
wanted = hex_to_bin(wanted.removeprefix("hex:"))
elif wanted.startswith("str:"):
wanted = wanted[4:].encode()
wanted = wanted.removeprefix("str:").encode()
else:
raise ValueError("unsupported search term")
except (ValueError, UnicodeEncodeError):

View file

@ -311,10 +311,7 @@ class RepositoryServer: # pragma: no cover
raise
sock_dir = os.path.dirname(self.socket_path)
os.makedirs(sock_dir, exist_ok=True)
if self.socket_path.endswith(".sock"):
pid_file = self.socket_path.replace(".sock", ".pid")
else:
pid_file = self.socket_path + ".pid"
pid_file = self.socket_path.removesuffix(".sock") + ".pid"
pid = os.getpid()
with open(pid_file, "w") as f:
f.write(str(pid))