Mercurial > treepkg
comparison contrib/sawmill/web/index.py @ 452:333232953771
Initial check-in of sawmill a simple mod_python based
web application to render build reports of treepkg.
author | Sascha Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 20 Aug 2010 16:15:29 +0000 |
parents | |
children | d8012571f9e1 |
comparison
equal
deleted
inserted
replaced
451:eacfd3744d16 | 452:333232953771 |
---|---|
1 # -*- coding: UTF-8 -*- | |
2 # | |
3 # Copyright (C) 2010 by Intevation GmbH | |
4 # Authors: | |
5 # Sascha L. Teichmann <sascha.teichmann@intevation.de> | |
6 # | |
7 # This program is free software under the GPL (>=v2) | |
8 # Read the file COPYING coming with the software for details. | |
9 | |
10 from mod_python import psp | |
11 | |
12 import os | |
13 | |
14 from lxml import etree | |
15 | |
16 TREEPKG_DIR = os.path.join(os.path.dirname(__file__), "treepkgs") | |
17 | |
18 def index(req): | |
19 req.content_type = 'text/html;charset=utf-8' | |
20 template = psp.PSP(req, filename='templates/overview.html') | |
21 | |
22 descriptions = [] | |
23 | |
24 for f in os.listdir(TREEPKG_DIR): | |
25 d = os.path.join(TREEPKG_DIR, f) | |
26 if not os.path.isdir(d): continue | |
27 treepkg_xml = os.path.join(d, "treepkg.xml") | |
28 if not os.path.isfile(treepkg_xml): continue | |
29 xml = None | |
30 try: | |
31 xml = open(treepkg_xml, "rb") | |
32 dom = etree.parse(xml) | |
33 finally: | |
34 if xml: xml.close() | |
35 | |
36 description = ''.join(dom.xpath("//description/text()")) | |
37 | |
38 descriptions.append((os.path.basename(d), description)) | |
39 | |
40 template.run({'descriptions': descriptions}) |