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()
|
self.rpc_thread.presence()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# raise (e)
|
# raise (e)
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,19 @@ import ast
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def update_plugin_json(plugin_info, category):
|
def update_plugin_json(plugin_info, category):
|
||||||
name = next(iter(plugin_info))
|
name = next(iter(plugin_info))
|
||||||
details = plugin_info[name]
|
details = plugin_info[name]
|
||||||
|
|
||||||
with open(f"{category}.json",'r+') as file:
|
with open(f"{category}.json", 'r+') as file:
|
||||||
data = json.load(file)
|
data = json.load(file)
|
||||||
try:
|
try:
|
||||||
# Check if plugin is already in the json
|
# Check if plugin is already in the json
|
||||||
data['plugins'][name]
|
data['plugins'][name]
|
||||||
plugman_version = int(next(iter(data["plugins"][name]["versions"])).replace('.', ''))
|
plugman_version = int(next(iter(data["plugins"][name]["versions"])).replace('.', ''))
|
||||||
current_version = int(next(iter(details["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:
|
if current_version > plugman_version or current_version == plugman_version:
|
||||||
data[name][details]["versions"][next(iter(details["versions"]))] = None
|
data[name][details]["versions"][next(iter(details["versions"]))] = None
|
||||||
elif current_version < plugman_version:
|
elif current_version < plugman_version:
|
||||||
|
|
@ -21,17 +22,18 @@ def update_plugin_json(plugin_info, category):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
data["plugins"][name] = details
|
data["plugins"][name] = details
|
||||||
file.seek(0)
|
file.seek(0)
|
||||||
json.dump(data, file, indent = 2, ensure_ascii=False)
|
json.dump(data, file, indent=2, ensure_ascii=False)
|
||||||
# Ensure old content is removed
|
# Ensure old content is removed
|
||||||
file.truncate()
|
file.truncate()
|
||||||
|
|
||||||
|
|
||||||
def extract_ba_plugman(plugins: str) -> dict | list:
|
def extract_ba_plugman(plugins: str) -> dict | list:
|
||||||
for plugin in plugins:
|
for plugin in plugins:
|
||||||
if "plugins/" in plugin:
|
if "plugins/" in plugin:
|
||||||
# Split the path and get the part after 'plugins/'
|
# Split the path and get the part after 'plugins/'
|
||||||
parts = plugin.split("plugins/")[1].split("/")
|
parts = plugin.split("plugins/")[1].split("/")
|
||||||
category = parts[0] # First part after plugins/
|
category = parts[0] # First part after plugins/
|
||||||
|
|
||||||
with open(plugin, "r") as f:
|
with open(plugin, "r") as f:
|
||||||
tree = ast.parse(f.read())
|
tree = ast.parse(f.read())
|
||||||
|
|
||||||
|
|
@ -45,8 +47,8 @@ def extract_ba_plugman(plugins: str) -> dict | list:
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Variable ba_plugman not found.")
|
raise ValueError(f"Variable ba_plugman not found.")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
plugins = sys.argv
|
plugins = sys.argv
|
||||||
extract_ba_plugman(plugins)
|
extract_ba_plugman(plugins)
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue