forked from Loy6410/ios16-tweaks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_readme.py
61 lines (47 loc) · 2.14 KB
/
generate_readme.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import yaml
import re
def load_yaml(file_path):
with open(file_path, 'r') as file:
return yaml.safe_load(file)
def sort_entries_by_name(entries):
return sorted(entries, key=lambda x: x['name'].lower())
def generate_markdown_table(entries, repos, category):
headers = "| Name | Repository |"
headers += " Issue |" if category == "not_working" else ""
header_separator = "| --- | --- |"
header_separator += " --- |" if category == "not_working" else ""
table = headers + "\n" + header_separator + "\n"
markdown_link_pattern = re.compile(r'\[.+\]\(.+\)')
for entry in entries:
repo_name = entry.get('repo', 'N/A')
if markdown_link_pattern.match(repo_name):
repo_markdown = repo_name
else:
repo_url = next((repo['url'] for repo in repos if repo['name'] == repo_name), None)
repo_markdown = f"[{repo_name}]({repo_url})" if repo_url else repo_name
row = f"| {entry['name']} | {repo_markdown} |"
row += f" {entry.get('issue', 'N/A')} |" if category == "not_working" else ""
table += row + "\n"
return table
def generate_repository_list(repos):
sorted_repos = sort_entries_by_name(repos)
markdown_list = "## Repositories\n"
for repo in sorted_repos:
markdown_list += f"- [{repo['name']}]({repo['url']})\n"
return markdown_list
def main():
data = load_yaml('data.yaml')
repos = data.get('repos', [])
markdown_content = "# iOS 16 Compatible Semi-Jailbreak Tweaks\n\n"
markdown_content += generate_repository_list(repos) + "\n"
for category in ['tweaks', 'themes', 'needs_testing', 'not_working']:
markdown_content += f"## {category.title().replace('_', ' ')}\n"
sorted_entries = sort_entries_by_name(data.get(category, []))
markdown_content += generate_markdown_table(sorted_entries, repos, category) + "\n"
markdown_content += "## Credits\n"
for credit in data.get('credits', []):
markdown_content += f"- [{credit['name']}]({credit['link']})\n"
with open('README.md', 'w') as file:
file.write(markdown_content)
if __name__ == "__main__":
main()