Use new removeprefix and removesuffix

This commit is contained in:
Safihre
2025-11-18 12:23:41 +01:00
parent 67a5a552fd
commit 9c8b26ab4e
4 changed files with 6 additions and 6 deletions

View File

@@ -382,7 +382,7 @@ class BPSMeter:
# Always trim the list to the max-length
if len(self.bps_list) > BPS_LIST_MAX:
self.bps_list = self.bps_list[len(self.bps_list) - BPS_LIST_MAX :]
self.bps_list = self.bps_list[-BPS_LIST_MAX:]
def get_sums(self):
"""return tuple of grand, month, week, day totals"""

View File

@@ -295,10 +295,10 @@ def sanitize_and_trim_path(path: str) -> str:
if sabnzbd.WINDOWS:
if path.startswith("\\\\?\\UNC\\"):
new_path = "\\\\?\\UNC\\"
path = path[8:]
path = path.removeprefix("\\\\?\\UNC\\")
elif path.startswith("\\\\?\\"):
new_path = "\\\\?\\"
path = path[4:]
path = path.removeprefix("\\\\?\\")
path = path.replace("\\", "/")
parts = path.split("/")

View File

@@ -1579,7 +1579,7 @@ def convert_sorter_settings():
def convert_history_retention():
"""Convert single-option to the split history retention setting"""
if "d" in cfg.history_retention():
days_to_keep = int_conv(cfg.history_retention().strip()[:-1])
days_to_keep = int_conv(cfg.history_retention().strip().removesuffix("d"))
cfg.history_retention_option.set("days-delete")
cfg.history_retention_number.set(days_to_keep)
else:

View File

@@ -283,7 +283,7 @@ class Sorter:
if ends_in_file(sort_string):
extension = True
if sort_string.endswith(".%ext"):
sort_string = sort_string[:-5] # Strip '.%ext' off the end; other %ext may remain in sort_string
sort_string = sort_string.removesuffix(".%ext") # Strip '.%ext' off the end; other %ext may remain
if self.is_season_pack:
# Create a record of the filename part of the sort_string
_, self.season_pack_setname = os.path.split(sort_string)
@@ -658,7 +658,7 @@ def guess_what(name: str) -> MatchesDict:
if digit_fix:
# Unfix the title
guess["title"] = guess.get("title", "")[len(digit_fix) :]
guess["title"] = guess.get("title", "").removeprefix(digit_fix)
# Handle weird anime episode notation, that results in the episode number ending up as the episode title
if (