Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
DoroWolf committed Dec 15, 2024
1 parent 30682c8 commit 8c758ef
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
3 changes: 3 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ dependency_file_paths = [
"pyproject.toml"
]

[analyzers.meta]
runtime_version = "3.x.x"

[[transformers]]
name = "black"
enabled = true
8 changes: 4 additions & 4 deletions core/scripts/config_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def generate_config(dir_path, language):
CFGManager.switch_config_path(dir_path)

for _dir in dir_list:
for root, _, files in os.walk(_dir):
for root, _, _files in os.walk(_dir):
if root in exclude_dir_list:
continue
for file in files:
for file in _files:
if file.endswith('.py'):
file_path = os.path.join(root, file)
with open(file_path, 'r', encoding='utf-8') as f:
Expand Down Expand Up @@ -153,8 +153,8 @@ def zip_language_folders(config_store_path, config_store_packed_path):
if not os.path.exists(config_store_path_bak):
repack = True
break
for root, _, files in os.walk(config_store_path_):
for file in files:
for root, _, files_ in os.walk(config_store_path_):
for file in files_:
file_path = os.path.join(root, file)
file_path_bak = file_path.replace(config_store_path, config_store_path_bak)
if not os.path.exists(file_path_bak):
Expand Down
20 changes: 10 additions & 10 deletions modules/core/su_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ async def _(msg: Bot.MessageSession):


@resume.command()
async def resume_sending_group_message(msg: Bot.MessageSession):
async def _(msg: Bot.MessageSession):
Temp.data['is_group_message_blocked'] = False
if targets := Temp.data['waiting_for_send_group_message']:
await msg.send_message(msg.locale.t("core.message.resume.processing", counts=len(targets)))
Expand All @@ -399,7 +399,7 @@ async def resume_sending_group_message(msg: Bot.MessageSession):


@resume.command('continue')
async def resume_sending_group_message(msg: Bot.MessageSession):
async def _(msg: Bot.MessageSession):
if not Temp.data['waiting_for_send_group_message']:
await msg.finish(msg.locale.t("core.message.resume.nothing"))
del Temp.data['waiting_for_send_group_message'][0]
Expand Down Expand Up @@ -545,15 +545,15 @@ async def _(msg: Bot.MessageSession, k: str, table_name: str = None):
else:
await msg.finish(msg.locale.t("message.failed"))

petal = module('petal', alias='petals', base=True, doc=True, load=Config('enable_petal', False))
petal_ = module('petal', alias='petals', base=True, doc=True, load=Config('enable_petal', False))


@petal.command('{{core.help.petal}}')
@petal_.command('{{core.help.petal}}')
async def _(msg: Bot.MessageSession):
await msg.finish(msg.locale.t('core.message.petal.self', petal=msg.petal))


@petal.command('[<sender>]', required_superuser=True, exclude_from=['TEST|Console'])
@petal_.command('[<sender>]', required_superuser=True, exclude_from=['TEST|Console'])
async def _(msg: Bot.MessageSession):
sender = msg.parsed_msg['<sender>']
if not any(sender.startswith(f'{sender_from}|') for sender_from in sender_list):
Expand All @@ -562,8 +562,8 @@ async def _(msg: Bot.MessageSession):
await msg.finish(msg.locale.t('core.message.petal', sender=sender, petal=sender_info.petal))


@petal.command('modify <petal>', available_for=['TEST|Console'])
@petal.command('modify <petal> [<sender>]', required_superuser=True, exclude_from=['TEST|Console'])
@petal_.command('modify <petal>', available_for=['TEST|Console'])
@petal_.command('modify <petal> [<sender>]', required_superuser=True, exclude_from=['TEST|Console'])
async def _(msg: Bot.MessageSession, petal: int, sender: str = None):
if sender:
if not any(sender.startswith(f'{sender_from}|') for sender_from in sender_list):
Expand All @@ -578,8 +578,8 @@ async def _(msg: Bot.MessageSession, petal: int, sender: str = None):
await msg.finish(msg.locale.t('core.message.petal.modify.self', add_petal=petal, petal=sender_info.petal))


@petal.command('clear', required_superuser=True, available_for=['TEST|Console'])
@petal.command('clear [<sender>]', required_superuser=True, exclude_from=['TEST|Console'])
@petal_.command('clear', required_superuser=True, available_for=['TEST|Console'])
@petal_.command('clear [<sender>]', required_superuser=True, exclude_from=['TEST|Console'])
async def _(msg: Bot.MessageSession, sender: str = None):
if sender:
if not any(sender.startswith(f'{sender_from}|') for sender_from in sender_list):
Expand All @@ -596,7 +596,7 @@ async def _(msg: Bot.MessageSession, sender: str = None):


@jobqueue.command('clear')
async def stop_playing_maimai(msg: Bot.MessageSession):
async def _(msg: Bot.MessageSession):
BotDBUtil.JobQueue.clear(0)
await msg.finish(msg.locale.t("message.success"))

Expand Down
39 changes: 18 additions & 21 deletions modules/wiki/utils/screenshot_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,14 @@ def join_url(base, target):
)

for x in soup.find_all("div"):
if x.has_attr("id"):
if x.get("id") in ["content", "mw-content-text"]:
fl = []
for f in x.attrs:
if isinstance(x.attrs[f], str):
fl.append(f'{f}="{x.attrs[f]}"')
elif isinstance(x.attrs[f], list):
fl.append(f'{f}="{" ".join(x.attrs[f])}"')
open_file.write(f'<div {" ".join(fl)}>')
if x.get("id") in ["content", "mw-content-text"]:
fl = []
for f in x.attrs:
if isinstance(x.attrs[f], str):
fl.append(f'{f}="{x.attrs[f]}"')
elif isinstance(x.attrs[f], list):
fl.append(f'{f}="{" ".join(x.attrs[f])}"')
open_file.write(f'<div {" ".join(fl)}>')
open_file.write('<div class="mw-parser-output">')

for x in soup.find_all("main"):
Expand Down Expand Up @@ -250,15 +249,14 @@ def join_url(base, target):
open_file.write(f'<body class="{" ".join(x.get("class"))}">')

for x in soup.find_all("div"):
if x.has_attr("id"):
if x.get("id") in ["content", "mw-content-text"]:
fl = []
for f in x.attrs:
if isinstance(x.attrs[f], str):
fl.append(f'{f}="{x.attrs[f]}"')
elif isinstance(x.attrs[f], list):
fl.append(f'{f}="{" ".join(x.attrs[f])}"')
open_file.write(f'<div {" ".join(fl)}>')
if x.get("id") in ["content", "mw-content-text"]:
fl = []
for f in x.attrs:
if isinstance(x.attrs[f], str):
fl.append(f'{f}="{x.attrs[f]}"')
elif isinstance(x.attrs[f], list):
fl.append(f'{f}="{" ".join(x.attrs[f])}"')
open_file.write(f'<div {" ".join(fl)}>')

open_file.write('<div class="mw-parser-output">')

Expand Down Expand Up @@ -306,9 +304,8 @@ def is_comment(e):

if b.name == selected_hx:
break
if b.name in hx:
if hx.index(selected_hx) >= hx.index(b.name):
break
if b.name in hx and hx.index(selected_hx) >= hx.index(b.name):
break
if b not in bl:
bl.append(str(b))
open_file.write("".join(bl))
Expand Down

0 comments on commit 8c758ef

Please sign in to comment.