From 9bac02922a0be9c54d5c6f9032c20624135d2549 Mon Sep 17 00:00:00 2001 From: Federico <84406177+Fedee0@users.noreply.github.com> Date: Sat, 14 Dec 2024 17:42:26 +0100 Subject: [PATCH 1/3] Create contributorsUpdater --- utils/contributorsUpdater | 73 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 utils/contributorsUpdater diff --git a/utils/contributorsUpdater b/utils/contributorsUpdater new file mode 100644 index 00000000..a1157022 --- /dev/null +++ b/utils/contributorsUpdater @@ -0,0 +1,73 @@ +import requests + +# Constants +GITHUB_API_URL = "https://api.github.com" +OUTPUT_FILE = "contributors.md" + + +def fetch_contributors_with_stats(owner, repo): + """Fetch contributors of the GitHub repository with their stats.""" + url = f"{GITHUB_API_URL}/repos/{owner}/{repo}/stats/contributors" + response = requests.get(url) + + if response.status_code != 200: + print(f"Failed to fetch contributors: {response.status_code} {response.text}") + return [] + + data = response.json() + if not data: + print("No contributors or stats data available.") + return [] + + contributors = [ + { + "login": contributor["author"]["login"], + "avatar_url": contributor["author"]["avatar_url"], + "lines_changed": sum(week["a"] + week["d"] for week in contributor["weeks"]), + } + for contributor in data + ] + + # Sort contributors by lines changed, descending + contributors.sort(key=lambda x: x["lines_changed"], reverse=True) + return contributors + + +def update_contributors_file(contributors): + """Update the Contributors file with the list of contributors.""" + with open(OUTPUT_FILE, "w") as file: + file.write("# **Contributors**\n\n") + file.write("This page is for crediting work of other people.\n\n") + file.write( + "Since this repository moved multiple times, a lot of contribution credits were lost.
\n" + ) + file.write( + "A lot of users spent much time on helping us adding more translations to this repository, we want to thank them with this list.\n\n" + ) + file.write("---\n\n") + + for contributor in contributors: + file.write( + f"[\"{contributor['login']}\"](https://github.com/{contributor['login']})" + ) + file.write("\n\n---\n") + + print(f"Contributors have been written to {OUTPUT_FILE}.") + + +def main(): + owner = "TechsCode" + repo = "PluginTranslations" + + print(f"Fetching contributors for {owner}/{repo}...") + contributors = fetch_contributors_with_stats(owner, repo) + + if contributors: + print(f"Fetched {len(contributors)} contributors.") + update_contributors_file(contributors) + else: + print("No contributors found or failed to fetch contributors.") + + +if __name__ == "__main__": + main() From a95498d4614f10f8ac10b8b5933b16cd04624a4f Mon Sep 17 00:00:00 2001 From: Federico <84406177+Fedee0@users.noreply.github.com> Date: Sat, 14 Dec 2024 17:46:58 +0100 Subject: [PATCH 2/3] Update contributorsUpdater --- utils/contributorsUpdater | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/contributorsUpdater b/utils/contributorsUpdater index a1157022..9a4f1f94 100644 --- a/utils/contributorsUpdater +++ b/utils/contributorsUpdater @@ -56,6 +56,7 @@ def update_contributors_file(contributors): def main(): + """Main function to execute the tool.""" owner = "TechsCode" repo = "PluginTranslations" From dcbcabdeab203066c8ff8f339376d04e7384f4f6 Mon Sep 17 00:00:00 2001 From: Federico <84406177+Fedee0@users.noreply.github.com> Date: Sat, 14 Dec 2024 17:47:42 +0100 Subject: [PATCH 3/3] Update CONTRIBUTORS.md --- CONTRIBUTORS.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 67f81894..8aff1189 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -7,16 +7,6 @@ A lot of users spent much time on helping us adding more translations to this re --- -[TehZombiJesus](https://github.com/TehZombiJesus)[timokueck](https://github.com/timokueck)[DAmNRelentless](https://github.com/DAmNRelentless)[Greazi-Timesk](https://github.com/Greazi-Times)[Serviettesky](https://github.com/Serviettesky)[Hitman477](https://github.com/Hitman477) - -[ItsWagPvP](https://github.com/ItsWagPvP)[EazyFTW](https://github.com/EazyFTW)[TechsCode](https://github.com/TechsCode)[MeepTortoise](https://github.com/MeepTortoise)[PanOkurka](https://github.com/PanOkurka)[editon96](https://github.com/editon96) - -[Fedee0](https://github.com/Fedee0)[Crosby601](https://github.com/Crosby601)[CREEPERGAMER138](https://github.com/CREEPERGAMER138)[NE137](https://github.com/NE137)[Kraineff](https://github.com/Kraineff)[Mellisen](https://github.com/Mellisen) - -[CraftJunkies](https://github.com/CraftJunkies)[iFlyinq](https://github.com/iFlyinq)[mrodz](https://github.com/mrodz)[faab007](https://github.com/faab007)[Im-Fran](https://github.com/Im-Fran)[codebyxemu](https://github.com/codebyxemu) - -[JamesBach93](https://github.com/JamesBach93)[Larskrs](https://github.com/Larskrs)[chickiyeah](https://github.com/chickiyeah)[Polda18](https://github.com/Polda18)[reussy](https://github.com/reussy)[dlsf](https://github.com/dlsf) - -[Mitricum](https://github.com/Mitricum) +[Greazi-Times](https://github.com/Greazi-Times)[Fedee0](https://github.com/Fedee0)[slaapkopamy](https://github.com/slaapkopamy)[TehZombiJesus](https://github.com/TehZombiJesus)[rlnt](https://github.com/rlnt)[timomatrix](https://github.com/timomatrix)[Serviettesky](https://github.com/Serviettesky)[OnlyMatty](https://github.com/OnlyMatty)[Hitman477](https://github.com/Hitman477)[PanOkurka](https://github.com/PanOkurka)[gabrielecabrini](https://github.com/gabrielecabrini)[SrLink16](https://github.com/SrLink16)[editon96](https://github.com/editon96)[chencu5958](https://github.com/chencu5958)[faab007nl](https://github.com/faab007nl)[Josesillo94](https://github.com/Josesillo94)[NE137](https://github.com/NE137)[Im-Fran](https://github.com/Im-Fran)[CraftJunkies](https://github.com/CraftJunkies)[Irowynn](https://github.com/Irowynn)[KahpotVanilla](https://github.com/KahpotVanilla)[Crosby601](https://github.com/Crosby601)[iFlyinq](https://github.com/iFlyinq)[WEBTER](https://github.com/WEBTER)[timokueck](https://github.com/timokueck)[Wolf-Organisation](https://github.com/Wolf-Organisation)[mrodz](https://github.com/mrodz)[enterih](https://github.com/enterih)[JamesBach93](https://github.com/JamesBach93)[ImYenil](https://github.com/ImYenil)[blixy77](https://github.com/blixy77)[YoshiiKun](https://github.com/YoshiiKun)[EazyFTW](https://github.com/EazyFTW)[MeepTortoise](https://github.com/MeepTortoise)[codebyxemu](https://github.com/codebyxemu)[MineTommy](https://github.com/MineTommy) ---