-
Notifications
You must be signed in to change notification settings - Fork 9
/
fetch-and-validate.py
43 lines (35 loc) · 1.7 KB
/
fetch-and-validate.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
"""Fetch ipk files from repositories and validate them."""
import argparse
from src.fetcher import Fetcher
from src.html import HTML
parser = argparse.ArgumentParser(
description="Fetch ipk's from repositories and validate them")
parser.add_argument("token", metavar="TOKEN", help="Github API token")
parser.add_argument("--config", dest="config_file", metavar="CONFIG",
default="./repositories.json", help="Path to config file")
parser.add_argument("--target", dest="ipk_target_dir", metavar="TARGET",
default="./build/packages",
help="Target dir for ipk downloads")
parser.add_argument("--html", dest="html_output_dir", metavar="HTML",
default="./build/packages",
help="Target dir for the HTML index file")
parser.add_argument("--template", dest="html_template", metavar="TEMPLATE",
default="./index.html",
help="Template file for HTML listing")
args = parser.parse_args()
token = args.token
config_file = args.config_file
ipk_target_dir = args.ipk_target_dir
html_output = "%s/index.html" % (args.html_output_dir)
html_template = args.html_template
html_output_prerelease = "%s-prerelease/index.html" % (args.html_output_dir)
# Fetch assets for stable and pre-releases
fetcher = Fetcher(token, config_file, ipk_target_dir)
packages = fetcher.fetch()
html = HTML(html_template)
# Write package index
stablePackages = sorted(packages['stable'], key=lambda d: d['Package'])
html.write(html_output, stablePackages)
# write package index for pre-releases
prereleasePackages = sorted(packages['prerelease'], key=lambda d: d['Package'])
html.write(html_output_prerelease, prereleasePackages)