#!/usr/bin/env python
import os, os.path, re, sys, gzip
from time import gmtime, strftime
def list_packages(distro, branch):
pkg_file = "dists/" + distro + "/" + branch + "/binary-i386/Packages.gz"
f=gzip.GzipFile(pkg_file, 'r')
contents=f.read()
f.close()
pkg_re = re.compile(r"Package: (.*)")
ver_re = re.compile(r"Version: (.*)")
desc_re = re.compile(r"Description: (.*)")
arch_re = re.compile(r"Architecture: (.*)")
pkg_list = pkg_re.search(contents)
ver_list = ver_re.search(contents)
desc_list = desc_re.search(contents)
arch_list = arch_re.search(contents)
pkg_i = pkg_re.finditer(contents)
ver_i = ver_re.finditer(contents)
desc_i = desc_re.finditer(contents)
arch_i = arch_re.finditer(contents)
html_table = ""
try:
while 1:
pkg = pkg_i.next()
ver = ver_i.next()
desc = desc_i.next()
arch = arch_i.next()
html_table = html_table + """
| " + \
pkg.group(1) + """ |
""" + ver.group(1) + """ |
""" + desc.group(1) + """ |
"""
except StopIteration: pass
html = """""" + distro +""" """ + branch + """:
| Package | Version | Description |
""" + html_table + """
"""
f = open('tempfile', 'r')
contents = f.read() + html
f.close()
f = open('tempfile', 'w')
f.write(contents)
f.close
try:
arg = sys.argv[1]
except:
arg=""
if arg == "-b":
cmd = "cd dists && ./create_repo.sh && cd .."
os.system(cmd)
f = open('tempfile', 'w')
f.write("")
f.close()
list_packages("dapper", "contrib")
f = open('tempfile', 'r')
contents = f.read()
f.close
f = open('index.html', 'r')
html_page = f.read()
f.close
html_re = re.compile(r"(.*)", re.S)
contents = """
""" + contents + """
"""
new_html = html_re.sub(contents, html_page)
today = strftime("%a, %d %b %Y", gmtime())
html_re = re.compile(r"(.*)", re.S)
new_date = """
"""
final_html = html_re.sub(new_date, new_html)
f = open('index.html', 'w')
f.write(final_html)
f.close