mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-06-01 17:03:37 +08:00
Fix: rename to removeprefix
This commit is contained in:
@@ -25,7 +25,7 @@ except KeyError:
|
||||
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+
|
||||
|
||||
@@ -36,7 +36,10 @@ def remove_suffix(s, suffix):
|
||||
Returns:
|
||||
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:
|
||||
@@ -71,7 +74,7 @@ class PackageCache:
|
||||
# adbutils-0.11.0-py3.7.egg-info
|
||||
res = re.match(r'^([a-zA-Z0-9._]+)-([a-zA-Z0-9._]+)-', file)
|
||||
if res:
|
||||
version = remove_suffix(res.group(2), '.dist')
|
||||
version = removesuffix(res.group(2), '.dist')
|
||||
# version = res.group(2)
|
||||
obj = FakeDistributionObject(
|
||||
dist=res.group(1),
|
||||
|
||||
@@ -5,7 +5,7 @@ from dataclasses import dataclass
|
||||
from tqdm import tqdm
|
||||
|
||||
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_KEY = re.compile(r'"(.*?)"')
|
||||
@@ -173,7 +173,7 @@ class SettingExtractor:
|
||||
if not settings:
|
||||
continue
|
||||
yield ''
|
||||
f = remove_prefix(file, folder).replace("\\", "/")
|
||||
f = removeprefix(file, folder).replace("\\", "/")
|
||||
yield f' # {f}'
|
||||
for setting in settings:
|
||||
if setting.key in dic_settings:
|
||||
|
||||
@@ -4,7 +4,7 @@ from scipy import signal
|
||||
|
||||
from module.base.decorator import cached_property
|
||||
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.ocr.ocr import Duration, Ocr
|
||||
from module.research.assets import *
|
||||
@@ -364,7 +364,7 @@ def research_jp_detect(image):
|
||||
"""
|
||||
project = ResearchProjectJp()
|
||||
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 == '':
|
||||
project.duration = '0'
|
||||
project.genre = get_research_genre_jp(image)
|
||||
|
||||
Reference in New Issue
Block a user