From 5ab3034a09ba6f53156e1917e13a5e577e2eb3cb Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Fri, 30 May 2025 11:17:06 +0300 Subject: [PATCH 01/26] See the output of the log --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de36220..1d5cc97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,7 @@ jobs: - name: Apply Version Metadata run: | + echo "Git commit short hash: $(git log --pretty=format:'%h' -n 1) python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1) - name: Commit Version Metadata From a3636afdd7a99efeb3fc06fc12410bc899ac2da1 Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Fri, 30 May 2025 11:19:51 +0300 Subject: [PATCH 02/26] forgot to close it --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d5cc97..2d0b266 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: - name: Apply Version Metadata run: | - echo "Git commit short hash: $(git log --pretty=format:'%h' -n 1) + echo "Git commit short hash: $(git log --pretty=format:'%h' -n 1)" python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1) - name: Commit Version Metadata From 1ab4e90004ea1ccebd2e6952c623e9fecb327056 Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Fri, 30 May 2025 11:26:48 +0300 Subject: [PATCH 03/26] revert changes --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d0b266..de36220 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,6 @@ jobs: - name: Apply Version Metadata run: | - echo "Git commit short hash: $(git log --pretty=format:'%h' -n 1)" python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1) - name: Commit Version Metadata From 04b15c625df7eba4e01b5ba3e42ee2460a630bab Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Fri, 30 May 2025 11:58:35 +0300 Subject: [PATCH 04/26] ... --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de36220..961d2bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,6 +43,7 @@ jobs: - name: Apply Version Metadata run: | + echo "Python files changed:" git diff --name-only HEAD~1 HEAD | grep ".py$" python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1) - name: Commit Version Metadata From 32eaa3f98e76e88badc15123640032e7f6eb0846 Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Fri, 30 May 2025 13:23:32 +0300 Subject: [PATCH 05/26] .. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 961d2bf..588c33d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: - name: Apply Version Metadata run: | - echo "Python files changed:" git diff --name-only HEAD~1 HEAD | grep ".py$" + echo "find . -type f -name "*.py" python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1) - name: Commit Version Metadata From 2386196ce786f452cb4881fbdb54563a6dd987c1 Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Fri, 30 May 2025 13:25:11 +0300 Subject: [PATCH 06/26] .. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 588c33d..12afa61 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: - name: Apply Version Metadata run: | - echo "find . -type f -name "*.py" + echo "find . -type f -name " python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1) - name: Commit Version Metadata From 9ec3d6efd4f3a0572223b8be9e4a1e484c62340c Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Fri, 30 May 2025 13:28:36 +0300 Subject: [PATCH 07/26] . --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 12afa61..59dba80 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,8 @@ jobs: - name: Apply Version Metadata run: | - echo "find . -type f -name " + echo "Python files found in the repository:" + find . -type f -name "*.py" python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1) - name: Commit Version Metadata From 710353a9a9361a344ce84fc55ee6c28b5a71c3b3 Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Fri, 30 May 2025 13:32:27 +0300 Subject: [PATCH 08/26] . --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 59dba80..3a166f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,8 +43,8 @@ jobs: - name: Apply Version Metadata run: | - echo "Python files found in the repository:" - find . -type f -name "*.py" + echo "Python files changed in PR:" + git diff --name-only origin/${{ github.base_ref }}..origin/${{ github.head_ref }} | grep ".py$" python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1) - name: Commit Version Metadata From 852a7b81ba4882d0f6988b58d5064cd1cfed302d Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Sun, 1 Jun 2025 15:36:32 +0300 Subject: [PATCH 09/26] . --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a166f0..bd20d67 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,8 +43,8 @@ jobs: - name: Apply Version Metadata run: | - echo "Python files changed in PR:" - git diff --name-only origin/${{ github.base_ref }}..origin/${{ github.head_ref }} | grep ".py$" + echo "Log:" + git log python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1) - name: Commit Version Metadata From 212a378cac97e679ca65005b1ff0b7b39ad0e7dd Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Sun, 1 Jun 2025 15:51:06 +0300 Subject: [PATCH 10/26] . --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd20d67..524406e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: - name: Apply Version Metadata run: | echo "Log:" - git log + git log --pretty=format:'%h' -n 1 python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1) - name: Commit Version Metadata From 2e1f7f5e65c4f7ddee425b46cc4ddb8c7f0f2127 Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Sun, 1 Jun 2025 15:59:07 +0300 Subject: [PATCH 11/26] . --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 524406e..d16c798 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,7 +44,7 @@ jobs: - name: Apply Version Metadata run: | echo "Log:" - git log --pretty=format:'%h' -n 1 + git log --pretty=format:'%H' -n 1 python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1) - name: Commit Version Metadata From 682ec721dbce6a0400e467c3bb3191f0a6fc8721 Mon Sep 17 00:00:00 2001 From: brostos <67740566+brostosjoined@users.noreply.github.com> Date: Sun, 1 Jun 2025 16:32:07 +0300 Subject: [PATCH 12/26] Update discord_richpresence.py --- plugins/utilities/discord_richpresence.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/utilities/discord_richpresence.py b/plugins/utilities/discord_richpresence.py index 94a09a5..7dcf216 100644 --- a/plugins/utilities/discord_richpresence.py +++ b/plugins/utilities/discord_richpresence.py @@ -4,8 +4,6 @@ # ba_meta require api 9 #!"Made to you by @brostos & @Dliwk" -# TODO -# - Update to the latest libs from __future__ import annotations From b6c8c79c726a1c1e297158a59d20bd516cf3ec67 Mon Sep 17 00:00:00 2001 From: brostos <67740566+brostosjoined@users.noreply.github.com> Date: Sun, 1 Jun 2025 16:47:32 +0300 Subject: [PATCH 13/26] Update forest.py --- plugins/maps/forest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/maps/forest.py b/plugins/maps/forest.py index d12fc3a..3730a4c 100644 --- a/plugins/maps/forest.py +++ b/plugins/maps/forest.py @@ -1,4 +1,5 @@ # ba_meta require api 9 +# from __future__ import annotations from typing import TYPE_CHECKING From 49e15591922ddd3cf79151e9c3ee3c29762d9348 Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Sun, 1 Jun 2025 16:49:55 +0300 Subject: [PATCH 14/26] ... --- plugins/maps/forest.py | 1 - plugins/minigames/air_soccer.py | 1 + plugins/utilities/discord_richpresence.py | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/maps/forest.py b/plugins/maps/forest.py index 3730a4c..d12fc3a 100644 --- a/plugins/maps/forest.py +++ b/plugins/maps/forest.py @@ -1,5 +1,4 @@ # ba_meta require api 9 -# from __future__ import annotations from typing import TYPE_CHECKING diff --git a/plugins/minigames/air_soccer.py b/plugins/minigames/air_soccer.py index 746909c..3ffdeb5 100644 --- a/plugins/minigames/air_soccer.py +++ b/plugins/minigames/air_soccer.py @@ -1,5 +1,6 @@ # Released under the MIT License. See LICENSE for details. # BY Stary_Agent +# """Hockey game and support classes.""" # ba_meta require api 9 diff --git a/plugins/utilities/discord_richpresence.py b/plugins/utilities/discord_richpresence.py index 7dcf216..28e2225 100644 --- a/plugins/utilities/discord_richpresence.py +++ b/plugins/utilities/discord_richpresence.py @@ -4,6 +4,7 @@ # ba_meta require api 9 #!"Made to you by @brostos & @Dliwk" +# from __future__ import annotations From 10c467b333c63bcc16cf7df9aae9d743b6ae13cd Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Sun, 1 Jun 2025 17:50:38 +0300 Subject: [PATCH 15/26] . --- .github/workflows/ci.yml | 7 ++++--- test/auto_apply_version_metadata.py | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d16c798..bf390bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,9 +43,10 @@ jobs: - name: Apply Version Metadata run: | - echo "Log:" - git log --pretty=format:'%H' -n 1 - python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1) + LAST_SHORTEN_COMMIT_HASH=$(git log --pretty=format:'%h' -n 1) + LAST_COMMIT_HASH=$(git log --pretty=format:'%H' -n 1) + CHANGED_FILES=$(git diff-tree --no-commit-id --name-only -r "$LAST_COMMIT_HASH") + python test/auto_apply_version_metadata.py "$LAST_SHORTEN_COMMIT_HASH" "$CHANGED_FILES" - name: Commit Version Metadata uses: stefanzweifel/git-auto-commit-action@v5 diff --git a/test/auto_apply_version_metadata.py b/test/auto_apply_version_metadata.py index af486fa..d764624 100644 --- a/test/auto_apply_version_metadata.py +++ b/test/auto_apply_version_metadata.py @@ -221,6 +221,7 @@ def auto_apply_version_metadata(last_commit_sha): if __name__ == "__main__": try: last_commit_sha = sys.argv[1] + print(type(sys.argv[1]), sys.argv[1]) except KeyError: raise ValueError("Last commit SHA not provided.") else: From c1bd1f8f01843d0592edc158ab27da237ae943b6 Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Sun, 1 Jun 2025 17:51:52 +0300 Subject: [PATCH 16/26] . --- test/auto_apply_version_metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/auto_apply_version_metadata.py b/test/auto_apply_version_metadata.py index d764624..ffdae9a 100644 --- a/test/auto_apply_version_metadata.py +++ b/test/auto_apply_version_metadata.py @@ -221,7 +221,7 @@ def auto_apply_version_metadata(last_commit_sha): if __name__ == "__main__": try: last_commit_sha = sys.argv[1] - print(type(sys.argv[1]), sys.argv[1]) + print(type(sys.argv[2]), sys.argv[2]) except KeyError: raise ValueError("Last commit SHA not provided.") else: From d61c2d3a880b36eaf9244b336ba8cff86c52fcd0 Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Sun, 1 Jun 2025 17:53:18 +0300 Subject: [PATCH 17/26] . --- test/auto_apply_version_metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/auto_apply_version_metadata.py b/test/auto_apply_version_metadata.py index ffdae9a..c424dd0 100644 --- a/test/auto_apply_version_metadata.py +++ b/test/auto_apply_version_metadata.py @@ -221,7 +221,7 @@ def auto_apply_version_metadata(last_commit_sha): if __name__ == "__main__": try: last_commit_sha = sys.argv[1] - print(type(sys.argv[2]), sys.argv[2]) + print(type(sys.argv), sys.argv) except KeyError: raise ValueError("Last commit SHA not provided.") else: From 0a6a7050b052437603eab512d9a7e4015b918da4 Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Sun, 1 Jun 2025 17:59:20 +0300 Subject: [PATCH 18/26] . --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf390bf..e2e5a18 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,6 +46,7 @@ jobs: LAST_SHORTEN_COMMIT_HASH=$(git log --pretty=format:'%h' -n 1) LAST_COMMIT_HASH=$(git log --pretty=format:'%H' -n 1) CHANGED_FILES=$(git diff-tree --no-commit-id --name-only -r "$LAST_COMMIT_HASH") + echo "$CHANGED_FILES" python test/auto_apply_version_metadata.py "$LAST_SHORTEN_COMMIT_HASH" "$CHANGED_FILES" - name: Commit Version Metadata From c92e07f5e98f40cd2c33814cf08e54581865d583 Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Sun, 1 Jun 2025 18:00:35 +0300 Subject: [PATCH 19/26] . --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2e5a18..50ef374 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: LAST_SHORTEN_COMMIT_HASH=$(git log --pretty=format:'%h' -n 1) LAST_COMMIT_HASH=$(git log --pretty=format:'%H' -n 1) CHANGED_FILES=$(git diff-tree --no-commit-id --name-only -r "$LAST_COMMIT_HASH") - echo "$CHANGED_FILES" + echo $CHANGED_FILES python test/auto_apply_version_metadata.py "$LAST_SHORTEN_COMMIT_HASH" "$CHANGED_FILES" - name: Commit Version Metadata From 9e98b694d7bca5a15be56997f9ea078dc5d0c74e Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Sun, 1 Jun 2025 18:01:53 +0300 Subject: [PATCH 20/26] . --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 50ef374..0d2f266 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: LAST_SHORTEN_COMMIT_HASH=$(git log --pretty=format:'%h' -n 1) LAST_COMMIT_HASH=$(git log --pretty=format:'%H' -n 1) CHANGED_FILES=$(git diff-tree --no-commit-id --name-only -r "$LAST_COMMIT_HASH") - echo $CHANGED_FILES + echo CHANGED_FILES python test/auto_apply_version_metadata.py "$LAST_SHORTEN_COMMIT_HASH" "$CHANGED_FILES" - name: Commit Version Metadata From 3d69cc4d54e528fdab0bf7b7d09b30982145213e Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Tue, 3 Jun 2025 17:16:50 +0300 Subject: [PATCH 21/26] Automate plugin metadata to respective json files. --- .github/workflows/ci.yml | 11 ++--- plugins/minigames/air_soccer.py | 1 - plugins/utilities/discord_richpresence.py | 5 ++- test/auto_apply_plugin_metadata.py | 52 +++++++++++++++++++++++ 4 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 test/auto_apply_plugin_metadata.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d2f266..c8e5e61 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,14 +40,15 @@ jobs: with: commit_message: "[ci] auto-format" branch: ${{ github.head_ref }} - - - name: Apply Version Metadata + - name: Apply Plugin Metadata run: | - LAST_SHORTEN_COMMIT_HASH=$(git log --pretty=format:'%h' -n 1) LAST_COMMIT_HASH=$(git log --pretty=format:'%H' -n 1) CHANGED_FILES=$(git diff-tree --no-commit-id --name-only -r "$LAST_COMMIT_HASH") - echo CHANGED_FILES - python test/auto_apply_version_metadata.py "$LAST_SHORTEN_COMMIT_HASH" "$CHANGED_FILES" + python test/auto_apply_plugin_metadata.py "$CHANGED_FILES" + + - name: Apply Version Metadata + run: | + python test/auto_apply_version_metadata.py $(git log --pretty=format:'%h' -n 1) - name: Commit Version Metadata uses: stefanzweifel/git-auto-commit-action@v5 diff --git a/plugins/minigames/air_soccer.py b/plugins/minigames/air_soccer.py index 3ffdeb5..746909c 100644 --- a/plugins/minigames/air_soccer.py +++ b/plugins/minigames/air_soccer.py @@ -1,6 +1,5 @@ # Released under the MIT License. See LICENSE for details. # BY Stary_Agent -# """Hockey game and support classes.""" # ba_meta require api 9 diff --git a/plugins/utilities/discord_richpresence.py b/plugins/utilities/discord_richpresence.py index 28e2225..46dbb57 100644 --- a/plugins/utilities/discord_richpresence.py +++ b/plugins/utilities/discord_richpresence.py @@ -4,7 +4,8 @@ # ba_meta require api 9 #!"Made to you by @brostos & @Dliwk" -# +# TODO +# - Update to the latest libs from __future__ import annotations @@ -1249,4 +1250,4 @@ class DiscordRP(babase.Plugin): self.rpc_thread.presence() except Exception as e: # raise (e) - pass + pass \ No newline at end of file diff --git a/test/auto_apply_plugin_metadata.py b/test/auto_apply_plugin_metadata.py new file mode 100644 index 0000000..58633fb --- /dev/null +++ b/test/auto_apply_plugin_metadata.py @@ -0,0 +1,52 @@ +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: + 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 + if current_version > plugman_version or current_version == plugman_version: + data[name][details]["versions"][next(iter(details["versions"]))] = None + elif current_version < plugman_version: + raise Exception('Version cant be lower than the previous') + except KeyError: + data["plugins"][name] = details + file.seek(0) + 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()) + + for node in ast.walk(tree): + if isinstance(node, ast.Assign): + # Check if the assignment matches our variable name + if len(node.targets) == 1 and getattr(node.targets[0], "id", None) == 'ba_plugman': + # Convert AST node to a Python object safely + # return ast.literal_eval(node.value) + update_plugin_json(ast.literal_eval(node.value), category) + break + else: + raise ValueError(f"Variable ba_plugman not found.") + +if __name__ == "__main__": + plugins = sys.argv + extract_ba_plugman(plugins) + \ No newline at end of file From 1f5348f51f55090a799ad974da03f9b8eb71fbbc Mon Sep 17 00:00:00 2001 From: brostosjoined <67740566+brostosjoined@users.noreply.github.com> Date: Tue, 3 Jun 2025 14:23:21 +0000 Subject: [PATCH 22/26] [ci] auto-format --- plugins/utilities/discord_richpresence.py | 2 +- test/auto_apply_plugin_metadata.py | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/plugins/utilities/discord_richpresence.py b/plugins/utilities/discord_richpresence.py index 46dbb57..94a09a5 100644 --- a/plugins/utilities/discord_richpresence.py +++ b/plugins/utilities/discord_richpresence.py @@ -1250,4 +1250,4 @@ class DiscordRP(babase.Plugin): self.rpc_thread.presence() except Exception as e: # raise (e) - pass \ No newline at end of file + pass diff --git a/test/auto_apply_plugin_metadata.py b/test/auto_apply_plugin_metadata.py index 58633fb..031a64b 100644 --- a/test/auto_apply_plugin_metadata.py +++ b/test/auto_apply_plugin_metadata.py @@ -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) - \ No newline at end of file From 12c81c9611a9746255bbc008ffabd78ce9b6fded Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Tue, 3 Jun 2025 17:37:55 +0300 Subject: [PATCH 23/26] Fix plugin path --- test/auto_apply_plugin_metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/auto_apply_plugin_metadata.py b/test/auto_apply_plugin_metadata.py index 031a64b..2b51d24 100644 --- a/test/auto_apply_plugin_metadata.py +++ b/test/auto_apply_plugin_metadata.py @@ -7,7 +7,7 @@ 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"plugins{category}.json", 'r+') as file: data = json.load(file) try: # Check if plugin is already in the json From 080281be49dc904da1098f439c8a91adb85eb628 Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Tue, 3 Jun 2025 17:39:47 +0300 Subject: [PATCH 24/26] Fix plugin path --- test/auto_apply_plugin_metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/auto_apply_plugin_metadata.py b/test/auto_apply_plugin_metadata.py index 2b51d24..4956a06 100644 --- a/test/auto_apply_plugin_metadata.py +++ b/test/auto_apply_plugin_metadata.py @@ -7,7 +7,7 @@ def update_plugin_json(plugin_info, category): name = next(iter(plugin_info)) details = plugin_info[name] - with open(f"plugins{category}.json", 'r+') as file: + with open(f"plugins{category}{category}.json", 'r+') as file: data = json.load(file) try: # Check if plugin is already in the json From 0da3ebca0b65f3a819848d8b54297fcbe6b592b9 Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Tue, 3 Jun 2025 17:42:01 +0300 Subject: [PATCH 25/26] forgot / --- test/auto_apply_plugin_metadata.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/auto_apply_plugin_metadata.py b/test/auto_apply_plugin_metadata.py index 4956a06..ec1f43e 100644 --- a/test/auto_apply_plugin_metadata.py +++ b/test/auto_apply_plugin_metadata.py @@ -7,7 +7,7 @@ def update_plugin_json(plugin_info, category): name = next(iter(plugin_info)) details = plugin_info[name] - with open(f"plugins{category}{category}.json", 'r+') as file: + with open(f"plugins/{category}/{category}.json", 'r+') as file: data = json.load(file) try: # Check if plugin is already in the json From 35012b68b510178bc633cc8d2a2dd06f7071056f Mon Sep 17 00:00:00 2001 From: brostosjoined Date: Wed, 4 Jun 2025 16:44:13 +0300 Subject: [PATCH 26/26] Support update of modder info --- test/auto_apply_plugin_metadata.py | 9 +++++++-- test/auto_apply_version_metadata.py | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/auto_apply_plugin_metadata.py b/test/auto_apply_plugin_metadata.py index ec1f43e..7c96352 100644 --- a/test/auto_apply_plugin_metadata.py +++ b/test/auto_apply_plugin_metadata.py @@ -11,12 +11,17 @@ def update_plugin_json(plugin_info, category): data = json.load(file) try: # Check if plugin is already in the json - data['plugins'][name] + plugin = 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 if current_version > plugman_version or current_version == plugman_version: - data[name][details]["versions"][next(iter(details["versions"]))] = None + plugin["versions"][next(iter(details["versions"]))] = None + # Ensure latest version appears first + plugin["versions"] = dict(sorted(plugin["versions"].items(), reverse=True)) + plugin["description"] = details["description"] + plugin["external_url"] = details["external_url"] + plugin["authors"] = details["authors"] elif current_version < plugman_version: raise Exception('Version cant be lower than the previous') except KeyError: diff --git a/test/auto_apply_version_metadata.py b/test/auto_apply_version_metadata.py index c424dd0..af486fa 100644 --- a/test/auto_apply_version_metadata.py +++ b/test/auto_apply_version_metadata.py @@ -221,7 +221,6 @@ def auto_apply_version_metadata(last_commit_sha): if __name__ == "__main__": try: last_commit_sha = sys.argv[1] - print(type(sys.argv), sys.argv) except KeyError: raise ValueError("Last commit SHA not provided.") else: