generatehtml.py 614 Bytes
Newer Older
Nikita Chernyi's avatar
Nikita Chernyi committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/usr/bin/env python3
import json
from pathlib import Path

def main():
    index = json.loads(Path('fdroid/repo/index-v1.json').read_text())
    apps = get_apps_html(index["apps"], index["packages"])
    layout = get_html(index["repo"], apps)
    print(layout)

def get_html(repo, apps):
    layout = Path('view/layout.html').read_text()
    return layout.format(repo=repo,appshtml=apps)

def get_apps_html(apps, packages):
    html = ""
    for app in apps:
        package = packages[app["packageName"]]
        html+= Path('view/app.html').read_text().format(app=app, package=package)
    return html

main()