From 11438e7c93fa7b7f36665f5892070d36c3b9fa67 Mon Sep 17 00:00:00 2001 From: p3xsouger Date: Thu, 18 Jul 2024 14:12:55 +0700 Subject: [PATCH] update_readme.py --- .github/test/update_readme.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/test/update_readme.py diff --git a/.github/test/update_readme.py b/.github/test/update_readme.py new file mode 100644 index 00000000..a8792eba --- /dev/null +++ b/.github/test/update_readme.py @@ -0,0 +1,17 @@ +import json + +with open('used_by_repos.json') as f: + data = json.load(f) + +repos = data.get('items', []) + +with open('readme.md', 'r') as f: + lines = f.readlines() + +start_idx = next(i for i, line in enumerate(lines) if line.strip() == "## Used By") + 1 +end_idx = next((i for i, line in enumerate(lines[start_idx:], start=start_idx) if line.startswith("##")), len(lines)) + +new_lines = lines[:start_idx] + [f"- [{repo['full_name']}]({repo['html_url']}): {repo.get('description', 'No description available')}\n" for repo in repos] + lines[end_idx:] + +with open('readme.md', 'w') as f: + f.writelines(new_lines)