| 1 |
#!/usr/bin/env python3 |
| 2 |
import json |
| 3 |
|
| 4 |
from jinja2 import Template |
| 5 |
|
| 6 |
template = Template(open("plugins.md").read()) |
| 7 |
|
| 8 |
blacklisted = [repo.strip() for repo in open("blacklisted.txt", "r").readlines()] |
| 9 |
|
| 10 |
PREFIX_LEN = len("https://github.com/") |
| 11 |
|
| 12 |
with open("repos.json", "r") as p: |
| 13 |
repos = json.load(p) |
| 14 |
|
| 15 |
# Removes the weird forks of errbot itself and |
| 16 |
# blacklisted repos |
| 17 |
filtered_plugins = [] |
| 18 |
for repo, plugins in repos.items(): |
| 19 |
for name, plugin in plugins.items(): |
| 20 |
if plugin["path"].startswith("errbot/builtins"): |
| 21 |
continue |
| 22 |
if plugin["repo"][PREFIX_LEN:] in blacklisted: |
| 23 |
continue |
| 24 |
filtered_plugins.append(plugin) |
| 25 |
|
| 26 |
sorted_plugins = sorted(filtered_plugins, key=lambda plugin: -plugin["score"]) |
| 27 |
|
| 28 |
with open("Home.md", "w") as out: |
| 29 |
out.write(template.render(plugins=sorted_plugins)) |