CI: fix a bug

This commit is contained in:
xtaodada 2023-07-01 20:31:50 +08:00
parent 2a75572349
commit 53b2340fe5
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 13 additions and 43 deletions

View File

@ -1069,36 +1069,6 @@
"supported": true, "supported": true,
"des_short": "miaolang 喵语翻译机", "des_short": "miaolang 喵语翻译机",
"des": "喵语翻译机\n\n指令:\n- `,enmiao <待转换文本> (支持回复消息)` (转换指定文本到喵语)\n- `,demiao <喵语> (支持回复消息)` (转换喵语到明文)" "des": "喵语翻译机\n\n指令:\n- `,enmiao <待转换文本> (支持回复消息)` (转换指定文本到喵语)\n- `,demiao <喵语> (支持回复消息)` (转换喵语到明文)"
},
{
"name": "chatgpt",
"version": "1.0",
"section": "chat",
"maintainer": "xtaodada",
"size": "4.129 kb",
"supported": true,
"des_short": ":recycle: Reformat All Plugins",
"des": ""
},
{
"name": "today_in_history",
"version": "1.0",
"section": "chat",
"maintainer": "xtaodada",
"size": "2.643 kb",
"supported": true,
"des_short": ":recycle: Reformat All Plugins",
"des": ""
},
{
"name": "trace",
"version": "1.0",
"section": "chat",
"maintainer": "xtaodada",
"size": "20.483 kb",
"supported": true,
"des_short": ":recycle: Reformat All Plugins",
"des": ""
} }
] ]
} }

View File

@ -26,20 +26,20 @@ delete = bool(main["commit"]["message"].startswith("Delete"))
for idx, plugins_ in enumerate([plugins, alpha_plugins]): for idx, plugins_ in enumerate([plugins, alpha_plugins]):
with open(f"{list_json_start[idx]}list.json", "r", encoding="utf8") as f: with open(f"{list_json_start[idx]}list.json", "r", encoding="utf8") as f:
list_json = json.load(f) list_json = json.load(f)
plugin_map = {i["name"]: i for i in list_json["list"]}
for plugin in plugins_: for plugin in plugins_:
exist = False if plugin in plugin_map:
for plug_dict in list_json["list"]: if delete:
if plug_dict["name"] == plugin: plugin_map.pop(plugin)
exist = True list_json["list"] = list(plugin_map.values())
continue
plug_dict = plugin_map[plugin]
old_version = decimal.Decimal(plug_dict["version"]) old_version = decimal.Decimal(plug_dict["version"])
plug_dict["version"] = str(old_version + decimal.Decimal("0.01")) plug_dict["version"] = str(old_version + decimal.Decimal("0.01"))
plug_dict[ plug_dict[
"size" "size"
] = f"{os.path.getsize(f'{list_json_start[idx]}{plugin}{os.sep}main.py') / 1000} kb" ] = f"{os.path.getsize(f'{list_json_start[idx]}{plugin}{os.sep}main.py') / 1000} kb"
if delete: else:
list_json["list"].remove(plug_dict)
break
if not exist:
short_des = main["commit"]["message"].split("\nCo-authored-by")[0].strip() short_des = main["commit"]["message"].split("\nCo-authored-by")[0].strip()
list_json["list"].append( list_json["list"].append(
{ {