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
e7476a6ae2
commit
86e3597513
1 changed files with 10 additions and 11 deletions
|
|
@ -3,6 +3,7 @@ import json
|
|||
import sys
|
||||
from urllib.request import urlopen
|
||||
|
||||
|
||||
def get_latest_version(plugin_name, category):
|
||||
base_url = "https://github.com/bombsquad-community/plugin-manager/raw/main/"
|
||||
endpoints = {
|
||||
|
|
@ -11,37 +12,36 @@ def get_latest_version(plugin_name, category):
|
|||
"maps": "plugins/maps.json",
|
||||
"plugman": "index.json"
|
||||
}
|
||||
|
||||
|
||||
try:
|
||||
with urlopen(f"{base_url}{endpoints[category]}") as response:
|
||||
data = json.loads(response.read().decode('utf-8'))
|
||||
|
||||
|
||||
# Handle plugman separately
|
||||
if category == "plugman":
|
||||
version = next(iter(data.get("versions")))
|
||||
return version
|
||||
|
||||
|
||||
# For plugins
|
||||
plugin = data.get("plugins", {}).get(plugin_name)
|
||||
if not plugin:
|
||||
return None
|
||||
|
||||
|
||||
# Get latest version from versions dict
|
||||
if "versions" in plugin and isinstance(plugin["versions"], dict):
|
||||
latest_version = next(iter(plugin["versions"])) # Gets first key
|
||||
return latest_version
|
||||
|
||||
|
||||
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
||||
|
||||
|
||||
def update_plugman_json(version):
|
||||
with open("index.json", "r+") as file:
|
||||
data = json.load(file)
|
||||
plugman_version = int(get_latest_version("plugin_manager", "plugman").replace(".", ""))
|
||||
current_version = int(version["version"].replace(".", ""))
|
||||
|
||||
|
||||
if current_version > plugman_version:
|
||||
with open("index.json", "r+") as file:
|
||||
data = json.load(file)
|
||||
|
|
@ -49,7 +49,6 @@ def update_plugman_json(version):
|
|||
data["versions"] = dict(
|
||||
sorted(data["versions"].items(), reverse=True)
|
||||
)
|
||||
|
||||
|
||||
|
||||
def update_plugin_json(plugin_info, category):
|
||||
|
|
@ -62,7 +61,7 @@ def update_plugin_json(plugin_info, category):
|
|||
plugin = data["plugins"][name]
|
||||
plugman_version = int(get_latest_version(name, category).replace(".", ""))
|
||||
current_version = int(plugin_info["version"].replace(".", ""))
|
||||
# Ensure the version is always greater from the already released version
|
||||
# Ensure the version is always greater from the already released version
|
||||
if current_version > plugman_version:
|
||||
plugin["versions"][plugin_info["version"]] = None
|
||||
# Ensure latest version appears first
|
||||
|
|
@ -94,7 +93,7 @@ def extract_plugman(plugins):
|
|||
try:
|
||||
# Split the path and get the part after 'plugins/'
|
||||
parts = plugin.split("plugins/")[1].split("/")
|
||||
category = parts[0] # First part after plugins/
|
||||
category = parts[0] # First part after plugins/
|
||||
except ValueError:
|
||||
if "plugin_manager" in plugin:
|
||||
continue
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue