| 1 |
#!/usr/bin/python |
#!/usr/bin/python |
| 2 |
# -*- coding: utf8 -*- |
# -*- coding: utf-8 -*- |
| 3 |
|
|
| 4 |
# Make sure tabs expand to 8 spaces in vim |
# Make sure tabs expand to 8 spaces in vim |
| 5 |
# vim: expandtab |
# vim: expandtab |
| 6 |
|
|
| 7 |
# Copyright 2002 Raphaël Hertzog |
# Copyright © 2002 Raphaël Hertzog |
| 8 |
|
# Copyright © 2009 Stefano Zacchiroli |
| 9 |
# This file is distributed under the terms of the General Public License |
# This file is distributed under the terms of the General Public License |
| 10 |
# version 2 or (at your option) any later version. |
# version 2 or (at your option) any later version. |
| 11 |
|
|
| 13 |
from xml.dom import implementation, ext |
from xml.dom import implementation, ext |
| 14 |
|
|
| 15 |
from config import dir, odir |
from config import dir, odir |
| 16 |
|
from common import hash_name |
| 17 |
|
|
| 18 |
|
bug_url_RE = re.compile(r'(http://bugs\.debian\.org/(\d+))') |
| 19 |
|
|
| 20 |
def striphtml(input): |
def striphtml(input): |
| 21 |
cleared = input.strip() |
cleared = input.strip() |
| 35 |
cleared = cleared.replace("<<", "<<"); |
cleared = cleared.replace("<<", "<<"); |
| 36 |
return cleared |
return cleared |
| 37 |
|
|
| 38 |
|
def bug_link_node(doc, bugno): |
| 39 |
|
a = doc.createElement("a") |
| 40 |
|
a.setAttribute("href", "http://bugs.debian.org/" + bugno) |
| 41 |
|
a.appendChild(doc.createTextNode("#" + bugno)) |
| 42 |
|
return a |
| 43 |
|
|
| 44 |
# Load the list of excuses generated last time |
# Load the list of excuses generated last time |
| 45 |
old_done = {} |
old_done = {} |
| 46 |
new_done = {} |
new_done = {} |
| 76 |
if top: |
if top: |
| 77 |
words = re.split("[><() ]", line) |
words = re.split("[><() ]", line) |
| 78 |
package = words[6] |
package = words[6] |
| 79 |
hash = package[0] |
hash = hash_name(package) |
|
if package[0:3] == "lib": |
|
|
hash = package[0:4] |
|
| 80 |
# Create the XML Document |
# Create the XML Document |
| 81 |
doc = implementation.createDocument(None, "excuse", None) |
doc = implementation.createDocument(None, "excuse", None) |
| 82 |
main_elt = doc.documentElement |
main_elt = doc.documentElement |
| 107 |
sub_elt = doc.createElement("item") |
sub_elt = doc.createElement("item") |
| 108 |
sub_elt.appendChild(doc.createTextNode(subline)) |
sub_elt.appendChild(doc.createTextNode(subline)) |
| 109 |
main_elt.appendChild(sub_elt) |
main_elt.appendChild(sub_elt) |
| 110 |
|
|
| 111 |
|
elif subline.find("introduces new bugs") != -1: |
| 112 |
|
bugs = [] |
| 113 |
|
m = bug_url_RE.search(subline) |
| 114 |
|
while m: |
| 115 |
|
_url, bug_no = m.groups() |
| 116 |
|
bugs.append(bug_no) |
| 117 |
|
m = bug_url_RE.search(subline, m.end()) |
| 118 |
|
|
| 119 |
|
sub_elt = doc.createElement("item") |
| 120 |
|
sub_elt.setAttribute("type", "raw") |
| 121 |
|
sub_elt.appendChild(doc.createTextNode( |
| 122 |
|
"Updating %s introduces new bugs: " % package)) |
| 123 |
|
main_elt.appendChild(sub_elt) |
| 124 |
|
first = True |
| 125 |
|
for bug in bugs: |
| 126 |
|
if first: |
| 127 |
|
first = False |
| 128 |
|
else: |
| 129 |
|
sub_elt.appendChild(doc.createTextNode(', ')) |
| 130 |
|
sub_elt.appendChild(bug_link_node(doc, bug)) |
| 131 |
|
sub_elt.appendChild(doc.createTextNode('.')) |
| 132 |
|
|
| 133 |
else: |
else: |
| 134 |
sub_elt = doc.createElement("item") |
sub_elt = doc.createElement("item") |
| 135 |
start = subline.find('href="http://') |
start = subline.find('href="http://') |
| 157 |
# and remove them |
# and remove them |
| 158 |
for p in old_done.keys(): |
for p in old_done.keys(): |
| 159 |
if not new_done.has_key(p): |
if not new_done.has_key(p): |
| 160 |
hash = p[0] |
hash = hash_name(p) |
|
if p[0:3] == "lib": |
|
|
hash = p[0:4] |
|
| 161 |
filename = "%s/%s/%s/excuse.xml" % (odir, hash, p) |
filename = "%s/%s/%s/excuse.xml" % (odir, hash, p) |
| 162 |
filenamerebuild = "%s/%s/%s/force-rebuild" % (odir, hash, p) |
filenamerebuild = "%s/%s/%s/force-rebuild" % (odir, hash, p) |
| 163 |
if os.path.exists(filename): |
if os.path.exists(filename): |