Skip to content

Commit

Permalink
重命名 AramHome 部分函数
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzaphkiel committed Jun 4, 2024
1 parent 02e5d87 commit e2ad1e8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
27 changes: 17 additions & 10 deletions app/common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

TAG = "Util"


class Github:
def __init__(self, user="Zzaphkiel", repositories="Seraphine"):
self.githubApi = "http://api.github.com"
Expand Down Expand Up @@ -61,7 +62,8 @@ def __get_ver_info(self):

res = self.sess.get(url, proxies=proxy).json()

json_data = json.loads(str(base64.b64decode(res['content']), encoding='utf-8'))
json_data = json.loads(
str(base64.b64decode(res['content']), encoding='utf-8'))

return json_data.get(VERSION, {})

Expand All @@ -85,7 +87,7 @@ def getNotice(self):

class AramHome:
"""
Power by: 大乱斗之家
Powered by: 大乱斗之家
Site: http://www.jddld.com
"""
ARAM_CFG_PATH = f"{LOCAL_PATH}/AramBuff.json"
Expand Down Expand Up @@ -116,11 +118,11 @@ async def checkAndUpdate(cls):
await m.__update()

@classmethod
def getInfoByHeroId(cls, heroid: str):
return cls.getInfoByField("heroid", heroid)
def getInfoByChampionId(cls, championId: str):
return cls.getInfoByField("heroid", championId)

@classmethod
def getInfoByHeroName(cls, name: str):
def getInfoByChampionName(cls, name: str):
return cls.getInfoByField("name", name)

@classmethod
Expand Down Expand Up @@ -182,7 +184,8 @@ async def __update(self):
'api_call_function': 'module_list',
'pagesize': '200' # FIXME 超过200个英雄会拿不完 -- By Hpero4
}
data = requests.get(url, params=params, proxies=None, verify=False).json() # 它不需要代理
data = requests.get(url, params=params, proxies=None,
verify=False).json() # 它不需要代理
if data.get("code") == 1:
with open(self.ARAM_CFG_PATH, "w") as f:
data = data.get("data")
Expand Down Expand Up @@ -228,7 +231,8 @@ def __checkUpdate(self):
with open(self.ARAM_CFG_PATH, "r") as f:
data = json.loads(f.read())
AramHome.data = data
dataVer = re.search(r"\d+\.\d+", data.get("banben", "")).group(0)
dataVer = re.search(
r"\d+\.\d+", data.get("banben", "")).group(0)
if dataVer and dataVer == lolVer:
return False

Expand Down Expand Up @@ -383,7 +387,8 @@ def getFileProperties(fname):
'FileDescription', 'LegalTrademarks', 'PrivateBuild',
'FileVersion', 'OriginalFilename', 'SpecialBuild')

props = {'FixedFileInfo': None, 'StringFileInfo': None, 'FileVersion': None}
props = {'FixedFileInfo': None,
'StringFileInfo': None, 'FileVersion': None}

try:
fixedInfo = win32api.GetFileVersionInfo(fname, '\\')
Expand All @@ -394,14 +399,16 @@ def getFileProperties(fname):

# \VarFileInfo\Translation returns list of available (language, codepage)
# pairs that can be used to retreive string info. We are using only the first pair.
lang, codepage = win32api.GetFileVersionInfo(fname, '\\VarFileInfo\\Translation')[0]
lang, codepage = win32api.GetFileVersionInfo(
fname, '\\VarFileInfo\\Translation')[0]

# any other must be of the form \StringfileInfo\%04X%04X\parm_name, middle
# two are language/codepage pair returned from above

strInfo = {}
for propName in propNames:
strInfoPath = u'\\StringFileInfo\\%04X%04X\\%s' % (lang, codepage, propName)
strInfoPath = u'\\StringFileInfo\\%04X%04X\\%s' % (
lang, codepage, propName)
strInfo[propName] = win32api.GetFileVersionInfo(fname, strInfoPath)

props['StringFileInfo'] = strInfo
Expand Down
8 changes: 4 additions & 4 deletions app/view/game_info_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
from app.components.animation_frame import CardWidget, ColorAnimationFrame
from app.lol.tools import parseSummonerOrder
from app.lol.connector import connector
from ..common.util import AramHome
from ..components.seraphine_interface import SeraphineInterface
from app.common.util import AramHome
from app.components.seraphine_interface import SeraphineInterface


class GameInfoInterface(SeraphineInterface):
Expand Down Expand Up @@ -132,7 +132,7 @@ async def updateAllyIcon(self, team):
view.updateIcon(icon)
if self.isAram:
view.updateAramInfo(
AramHome.getInfoByHeroId(str(newChampionId)))
AramHome.getInfoByChampionId(str(newChampionId)))

async def clear(self):
self.allyChampions = {}
Expand Down Expand Up @@ -279,7 +279,7 @@ def updateSummoners(self, summoners, isAram=False):
continue

if isAram and summoner["championId"]:
aramInfo = AramHome.getInfoByHeroId(
aramInfo = AramHome.getInfoByChampionId(
str(summoner["championId"]))
else:
aramInfo = None
Expand Down

0 comments on commit e2ad1e8

Please sign in to comment.