/[qa]/trunk/data/ddpo/extract_excuses.py
ViewVC logotype

Contents of /trunk/data/ddpo/extract_excuses.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1225 - (show annotations) (download) (as text)
Tue Jan 17 13:44:54 2006 UTC (7 years, 5 months ago) by myon
File MIME type: text/x-python
File size: 3087 byte(s)
move excuses extraction to separate program, let it write a db file; put package-per-maintainer and maintainer-of-package in ddpo_packages.db
1 #! /usr/bin/env python2.3
2 # Copyright (C) 2002 Igor Genibel
3 # Copyright (C) 2006 Christoph Berg <myon@debian.org>
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14
15 # $Id$
16
17 import sys, os, re, urllib, dbm, signal
18
19 def alarmHandler(*args):
20 """
21 signal handler for SIGALRM, just raise an exception
22 """
23 raise "TimeOut"
24
25 def extract_excuses():
26 excuses_db = dbm.open("excuses-new", 'c')
27 signal.signal(signal.SIGALRM, alarmHandler)
28 try:
29 # set timeout
30 signal.alarm(10)
31 excuse_file = urllib.urlopen("http://ftp-master.debian.org/testing/update_excuses.html")
32 signal.alarm(0)
33 except "TimeOut":
34 print >> sys.stderr, "[WARNING: skipping testing-excuses due to ftp-master timeout!"
35 signal.alarm(0)
36 return
37
38 re_id = re.compile(r'^<li><a id="(.+?)"\s.+\((.+?)\sto.+')
39 re_ul = re.compile(r'</ul>')
40 re_dep = re.compile(r'<li>Depends: .+ <a href="#(.+?)"')
41 re_maint = re.compile(r'<li>Maintainer:')
42 re_dash = re.compile(r'^-.+')
43 re_slash = re.compile(r'.+/.+')
44 re_less = re.compile(r'<=')
45 re_greater = re.compile(r'> 0')
46 re_target = re.compile(r' target="_blank"')
47
48 opened = 0
49 package = ""
50 excuse = ""
51 valid = 0
52
53 while 1:
54 line = excuse_file.readline()
55 if line == "": break
56 match_id = re_id.search(line)
57 match_ul = re_ul.search(line)
58 match_dep = re_dep.search(line)
59 if re_maint.match(line):
60 continue
61
62 if match_id:
63 package = match_id.group(1)
64 match_dash = re_dash.search(package)
65 if match_dash:
66 continue
67 match_slash = re_slash.search(package)
68 if match_slash:
69 continue
70 version = match_id.group(2)
71 excuse = "<!-- Testing_version: "+version+" -->\n"
72 excuse += "<h2>Excuse for "+package+"</h2>\n"
73 opened = 1
74 valid = 1
75
76 elif match_ul and (valid == 1):
77 excuse += '</ul>'
78 excuses_db[package] = excuse
79 package = ""
80 opened = 0
81 valid = 0
82
83 elif match_dep and (valid == 1):
84 link = match_dep.group(1)
85 excuse += '<li>Depends: '+package+' <a href="developer.php?excuse='+link+'">'+link+'</a></li>\n'
86
87 elif (opened == 1) and (valid == 1):
88 line = re_less.sub('&lt;=', line)
89 line = re_greater.sub('&gt; 0', line)
90 line = re_target.sub('', line)
91 excuse += line
92
93 excuses_db.close()
94 return
95
96 extract_excuses()
97
98 # vim:sw=4:softtabstop=4:expandtab

Properties

Name Value
svn:eol-style native
svn:executable *
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.5