mirror of
https://github.com/bombsquad-community/plugin-manager.git
synced 2025-10-08 14:54:36 +00:00
[ci] auto-format
This commit is contained in:
parent
3d69cc4d54
commit
1f5348f51f
2 changed files with 12 additions and 10 deletions
|
|
@ -1250,4 +1250,4 @@ class DiscordRP(babase.Plugin):
|
|||
self.rpc_thread.presence()
|
||||
except Exception as e:
|
||||
# raise (e)
|
||||
pass
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -2,18 +2,19 @@ import ast
|
|||
import json
|
||||
import sys
|
||||
|
||||
|
||||
def update_plugin_json(plugin_info, category):
|
||||
name = next(iter(plugin_info))
|
||||
details = plugin_info[name]
|
||||
|
||||
with open(f"{category}.json",'r+') as file:
|
||||
|
||||
with open(f"{category}.json", 'r+') as file:
|
||||
data = json.load(file)
|
||||
try:
|
||||
# Check if plugin is already in the json
|
||||
data['plugins'][name]
|
||||
plugman_version = int(next(iter(data["plugins"][name]["versions"])).replace('.', ''))
|
||||
current_version = int(next(iter(details["versions"])).replace('.', ''))
|
||||
# `or` In case another change was made on the plugin while still on pr
|
||||
# `or` In case another change was made on the plugin while still on pr
|
||||
if current_version > plugman_version or current_version == plugman_version:
|
||||
data[name][details]["versions"][next(iter(details["versions"]))] = None
|
||||
elif current_version < plugman_version:
|
||||
|
|
@ -21,17 +22,18 @@ def update_plugin_json(plugin_info, category):
|
|||
except KeyError:
|
||||
data["plugins"][name] = details
|
||||
file.seek(0)
|
||||
json.dump(data, file, indent = 2, ensure_ascii=False)
|
||||
# Ensure old content is removed
|
||||
json.dump(data, file, indent=2, ensure_ascii=False)
|
||||
# Ensure old content is removed
|
||||
file.truncate()
|
||||
|
||||
|
||||
|
||||
def extract_ba_plugman(plugins: str) -> dict | list:
|
||||
for plugin in plugins:
|
||||
if "plugins/" in plugin:
|
||||
# Split the path and get the part after 'plugins/'
|
||||
parts = plugin.split("plugins/")[1].split("/")
|
||||
category = parts[0] # First part after plugins/
|
||||
|
||||
|
||||
with open(plugin, "r") as f:
|
||||
tree = ast.parse(f.read())
|
||||
|
||||
|
|
@ -45,8 +47,8 @@ def extract_ba_plugman(plugins: str) -> dict | list:
|
|||
break
|
||||
else:
|
||||
raise ValueError(f"Variable ba_plugman not found.")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
plugins = sys.argv
|
||||
extract_ba_plugman(plugins)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue