1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-06-02 00:03:35 +08:00

Fix: rename to removeprefix

This commit is contained in:
LmeSzinc
2026-05-22 18:42:11 +08:00
parent 4d836d34cf
commit 0491a0e47d
3 changed files with 10 additions and 7 deletions

View File

@@ -25,7 +25,7 @@ except KeyError:
logger.error('Patch pkg_resources failed, patch module does not exists') logger.error('Patch pkg_resources failed, patch module does not exists')
def remove_suffix(s, suffix): def removesuffix(s, suffix):
""" """
Remove suffix of a string or bytes like `string.removesuffix(suffix)`, which is on Python3.9+ Remove suffix of a string or bytes like `string.removesuffix(suffix)`, which is on Python3.9+
@@ -36,7 +36,10 @@ def remove_suffix(s, suffix):
Returns: Returns:
str, bytes: str, bytes:
""" """
return s[:-len(suffix)] if s.endswith(suffix) else s # s[:-0] is empty string, so we need to check if suffix is empty
if suffix and s.endswith(suffix):
return s[:-len(suffix)]
return s
class FakeDistributionObject: class FakeDistributionObject:
@@ -71,7 +74,7 @@ class PackageCache:
# adbutils-0.11.0-py3.7.egg-info # adbutils-0.11.0-py3.7.egg-info
res = re.match(r'^([a-zA-Z0-9._]+)-([a-zA-Z0-9._]+)-', file) res = re.match(r'^([a-zA-Z0-9._]+)-([a-zA-Z0-9._]+)-', file)
if res: if res:
version = remove_suffix(res.group(2), '.dist') version = removesuffix(res.group(2), '.dist')
# version = res.group(2) # version = res.group(2)
obj = FakeDistributionObject( obj = FakeDistributionObject(
dist=res.group(1), dist=res.group(1),

View File

@@ -5,7 +5,7 @@ from dataclasses import dataclass
from tqdm import tqdm from tqdm import tqdm
from module.base.decorator import cached_property from module.base.decorator import cached_property
from module.device.method.utils import remove_prefix from module.device.method.utils import removeprefix
REGEX_SETTING = re.compile(r'PlayerPrefs.Get(\w{1,10})\((.*)\)') REGEX_SETTING = re.compile(r'PlayerPrefs.Get(\w{1,10})\((.*)\)')
REGEX_SETTING_KEY = re.compile(r'"(.*?)"') REGEX_SETTING_KEY = re.compile(r'"(.*?)"')
@@ -173,7 +173,7 @@ class SettingExtractor:
if not settings: if not settings:
continue continue
yield '' yield ''
f = remove_prefix(file, folder).replace("\\", "/") f = removeprefix(file, folder).replace("\\", "/")
yield f' # {f}' yield f' # {f}'
for setting in settings: for setting in settings:
if setting.key in dic_settings: if setting.key in dic_settings:

View File

@@ -4,7 +4,7 @@ from scipy import signal
from module.base.decorator import cached_property from module.base.decorator import cached_property
from module.base.utils import * from module.base.utils import *
from module.device.method.utils import remove_suffix from module.device.method.utils import removesuffix
from module.logger import logger from module.logger import logger
from module.ocr.ocr import Duration, Ocr from module.ocr.ocr import Duration, Ocr
from module.research.assets import * from module.research.assets import *
@@ -364,7 +364,7 @@ def research_jp_detect(image):
""" """
project = ResearchProjectJp() project = ResearchProjectJp()
project.series = get_research_series_jp(image) project.series = get_research_series_jp(image)
project.duration = remove_suffix(str(get_research_duration_jp(image) / 3600), '.0') project.duration = removesuffix(str(get_research_duration_jp(image) / 3600), '.0')
if project.duration == '': if project.duration == '':
project.duration = '0' project.duration = '0'
project.genre = get_research_genre_jp(image) project.genre = get_research_genre_jp(image)