Skip to content

Commit

Permalink
使用black格式化
Browse files Browse the repository at this point in the history
  • Loading branch information
AutumnSun1996 committed Mar 24, 2024
1 parent 052131e commit ffe57bc
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
5 changes: 4 additions & 1 deletion utils/cats.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ def get_cat_talents():
m = re.search(r'^\[\[File:(.+?)\|.+\]\]\s*(.+)$', cell)
src, name = m.groups()
talents.append(
{'name': name, 'img': src,}
{
'name': name,
'img': src,
}
)
return talents

Expand Down
1 change: 0 additions & 1 deletion utils/crawl.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,3 @@ def get_categorymember_details(category):
for f in as_completed(fs):
resp = f.result()
yield json.loads(resp)

18 changes: 6 additions & 12 deletions utils/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,19 @@ def __init__(self, name, data, inv_data) -> None:
self.inv_data = inv_data

def __getitem__(self, key):
"""从名称获取编号
"""
"""从名称获取编号"""
return self.data[key]

def get(self, key):
"""从编号获取名称, 或者从名称获取编号
"""
"""从编号获取名称, 或者从名称获取编号"""
if key in self.data:
return self.data[key]
if key in self.inv_data:
return self.inv_data[key]
raise KeyError(key)

def inv(self, key):
"""从编号获取名称
"""
"""从编号获取名称"""
return self.inv_data[key]

def __repr__(self) -> str:
Expand All @@ -33,20 +30,17 @@ def __repr__(self) -> str:
__str__ = __repr__

def __contains__(self, other):
"""检查指定值是否是已知的编号或名称
"""
"""检查指定值是否是已知的编号或名称"""
return other in self.data or other in self.inv_data

def force_repr(self, key):
"""将非标准的名称或者编号转化为统一的名称
"""
"""将非标准的名称或者编号转化为统一的名称"""
if key in self.data:
key = self.data[key]
return self.inv_data[key]

def force_data(self, key):
"""将非标准的名称或者编号转化为编号
"""
"""将非标准的名称或者编号转化为编号"""
if key in self.inv_data:
return key
return self.data[key]
Expand Down
4 changes: 3 additions & 1 deletion utils/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def crawl_cat_icon():
for item in items:
name = item['name'] + '头像.png'
f = crawl_image(
executor, name, 'resources/cache/images/指挥喵头像/%s' % sanitize_filename(name),
executor,
name,
'resources/cache/images/指挥喵头像/%s' % sanitize_filename(name),
)
fs.append(f)
for f in fs:
Expand Down
15 changes: 14 additions & 1 deletion utils/ship_trans.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,20 @@ def get_attr(raw, key):
code = raw['编号']
if code.isnumeric():
code = "N" + code
if key in ('耐久', '装填', '炮击', '雷击', '机动', '防空', '航空', '反潜',) and code in attrs:
if (
key
in (
'耐久',
'装填',
'炮击',
'雷击',
'机动',
'防空',
'航空',
'反潜',
)
and code in attrs
):
data = attrs[code]
lvl = 120
val = (
Expand Down

0 comments on commit ffe57bc

Please sign in to comment.