消除几个报错

This commit is contained in:
qwerdvd 2023-10-21 11:55:35 +08:00
parent 99fd1d2cbb
commit 30818559cd
No known key found for this signature in database
GPG Key ID: A3AF89C783404769
2 changed files with 40 additions and 38 deletions

View File

@ -1,32 +1,18 @@
import copy
import json
import math
import textwrap
from pathlib import Path
from typing import Dict, Union
import copy
from PIL import Image, ImageDraw
from gsuid_core.logger import logger
from gsuid_core.utils.image.convert import convert_img
from gsuid_core.utils.image.image_tools import draw_text_by_line
from PIL import Image, ImageDraw
from .to_data import api_to_dict
from ..utils.error_reply import CHAR_HINT
from .cal_damage import cal, cal_char_info, cal_info
from ..utils.fonts.first_world import fw_font_28
from ..utils.excel.read_excel import light_cone_ranks
from ..utils.map.name_covert import name_to_avatar_id, alias_to_char_name
from ..utils.map.SR_MAP_PATH import (
RelicId2Rarity,
AvatarRelicScore,
avatarId2Name,
)
from ..utils.resource.RESOURCE_PATH import (
RELIC_PATH,
SKILL_PATH,
PLAYER_PATH,
WEAPON_PATH,
CHAR_PORTRAIT_PATH,
)
from ..utils.fonts.first_world import fw_font_28
from ..utils.fonts.starrail_fonts import (
sr_font_18,
sr_font_20,
@ -37,6 +23,21 @@ from ..utils.fonts.starrail_fonts import (
sr_font_34,
sr_font_38,
)
from ..utils.map.name_covert import alias_to_char_name, name_to_avatar_id
from ..utils.map.SR_MAP_PATH import (
AvatarRelicScore,
RelicId2Rarity,
avatarId2Name,
)
from ..utils.resource.RESOURCE_PATH import (
CHAR_PORTRAIT_PATH,
PLAYER_PATH,
RELIC_PATH,
SKILL_PATH,
WEAPON_PATH,
)
from .cal_damage import cal_char_info, cal_info
from .to_data import api_to_dict
Excel_path = Path(__file__).parent / 'damage'
with Path.open(Excel_path / 'Excel' / 'SkillData.json', encoding='utf-8') as f:
@ -611,6 +612,7 @@ async def draw_char_img(char_data: Dict, sr_uid: str, msg: str):
if damage_len > 0:
damage_title_img = Image.open(TEXT_PATH / 'base_info_pure.png')
char_info.paste(damage_title_img, (0, 2028), damage_title_img)
damage_list = []
# damage_list = await cal(char_data)
# 写伤害
char_img_draw.text(

View File

@ -2,33 +2,33 @@ import asyncio
from pathlib import Path
from typing import Dict, List, Tuple, Union
from bs4 import BeautifulSoup
from msgspec import json as msgjson
from gsuid_core.logger import logger
from aiohttp import ClientTimeout, TCPConnector
from aiohttp.client import ClientSession
from aiohttp import TCPConnector, ClientTimeout
from gsuid_core.utils.download_resource.download_file import download
from bs4 import BeautifulSoup
from gsuid_core.logger import logger
from gsuid_core.utils.download_resource.download_core import check_url
from gsuid_core.utils.download_resource.download_file import download
from msgspec import json as msgjson
from .download_url import download_file
from .RESOURCE_PATH import (
WIKI_PATH,
CHAR_ICON_PATH,
CHAR_PORTRAIT_PATH,
CHAR_PREVIEW_PATH,
CONSUMABLE_PATH,
ELEMENT_PATH,
GUIDE_CHARACTER_PATH,
GUIDE_LIGHT_CONE_PATH,
GUIDE_PATH,
RELIC_PATH,
RESOURCE_PATH,
SKILL_PATH,
WEAPON_PATH,
ELEMENT_PATH,
RESOURCE_PATH,
CHAR_ICON_PATH,
WIKI_ROLE_PATH,
CONSUMABLE_PATH,
WIKI_RELIC_PATH,
CHAR_PREVIEW_PATH,
CHAR_PORTRAIT_PATH,
GUIDE_CHARACTER_PATH,
WIKI_LIGHT_CONE_PATH,
GUIDE_LIGHT_CONE_PATH,
WIKI_MATERIAL_FOR_ROLE,
WIKI_PATH,
WIKI_RELIC_PATH,
WIKI_ROLE_PATH,
)
with Path.open(
@ -45,15 +45,15 @@ async def find_fastest_url(urls: Dict[str, str]):
for tag in urls:
tasks.append(asyncio.create_task(check_url(tag, urls[tag])))
results: list[tuple[str, str, float]] = await asyncio.gather(
*tasks, return_exceptions=True
)
results: list[
tuple[str, str, float] | BaseException
] = await asyncio.gather(*tasks, return_exceptions=True)
fastest_tag = ''
fastest_url = None
fastest_time = float('inf')
for result in results:
if isinstance(result, Exception):
if isinstance(result, BaseException):
continue
tag, url, elapsed_time = result
if elapsed_time < fastest_time: