/[qa]/trunk/pts/www/bin/other_to_xml.py
ViewVC logotype

Diff of /trunk/pts/www/bin/other_to_xml.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1882 by hertzog, Fri Jun 6 10:42:02 2008 UTC revision 2231 by zack, Thu Jul 23 10:41:30 2009 UTC
# Line 1  Line 1 
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 2005 Jeroen van Wolffelaar  # Copyright: © 2005 Jeroen van Wolffelaar
9  # Copyright 2007-2008 Stefano Zacchiroli  # Copyright: © 2007-2009 Stefano Zacchiroli
10  # This file is distributed under the terms of the General Public License  # This file is distributed under the terms of the General Public License
11  # version 2 or (at your option) any later version.  # version 2 or (at your option) any later version.
12    
13  import os.path, rfc822, sys, string, re, email, common, cPickle, syck  import os.path, sys, string, re, email, common, cPickle, yaml
14  from xml.dom import implementation, ext  from xml.dom import implementation, ext
15    from debian_bundle import deb822, debian_support
16    
17  from config import dir, odir, root  from config import dir, odir, root
18    from common import hash_name
19    
20  # Create the source -> binaries correspondance  # sources <-> binaries correspondances, kind of global variables
21  sources = {}  source2binaries = {} # maps a source package to its binaries
22    binary2source = {}   # maps a binary package to its source
23    
24    def read_shortdesc(fname):
25        global binary2source
26        source_descs = {} # source package -> (binary package -> short description)
27        for line in open(fname):
28            pkg, shortdesc = line.strip().split("\t", 1)
29            if not binary2source.has_key(pkg):
30                continue
31            src = binary2source[pkg]
32            if not source_descs.has_key(src):
33                source_descs[src] = {}
34            source_descs[src][pkg] = shortdesc
35        return source_descs
36    
37    def read_bug_summary(fname):
38        global binary2source
39        summary = {} # source package -> bug count
40        for line in open(fname):
41            pkg, count = line.split()
42            if not binary2source.has_key(pkg):
43                continue
44            src = binary2source[pkg]
45            if not summary.has_key(src):
46                summary[src] = 0
47            summary[src] += int(count)
48        return summary
49    
50    def read_low_threshold_nmu(fname):
51        """read low threshold NMU info"""
52        emails = []
53        if os.path.exists(fname):
54            f = open(fname)
55            devel_php_RE = \
56                re.compile(r'http://qa\.debian\.org/developer\.php\?login=([^\s&]+)')
57            word_RE = re.compile(r'^\w+$')
58            for line in f.readlines():
59                match = devel_php_RE.search(line)
60                while match:    # look for several matches on the same line
61                    email = None
62                    login = match.group(1)
63                    if word_RE.match(login):
64                        email = login + '@debian.org'
65                    elif login.find('@') >= 0:
66                        email = login
67                    if email:
68                        emails.append(email)
69                    line = line[match.end():]
70                    match = devel_php_RE.search(line)
71            f.close()
72        return emails
73    
74    def read_transitions(fname):
75        y = yaml.load(file(fname))
76        packages = {} # maps pkg to the _list_ of transitions they are involved in
77        for id, transition in y.iteritems():
78            for pkg in transition['packages']:
79                if not packages.has_key(pkg):
80                    packages[pkg] = []
81                packages[pkg].append(id)
82        return packages
83    
84    def read_piuparts(fname):
85        failures = {}
86        if os.path.exists(fname):
87            f = open(fname)
88            for line in f.readlines():
89                try:
90                    src, outcome = map(lambda s: s.strip(), line.split(':'))
91                    if outcome == "fail":
92                        failures[src] = True
93                except ValueError:
94                    pass
95            f.close()
96        return failures
97    
98    def read_lintian_info(fname):
99        lintian = {} # maps source pkg names to pairs <errors_no, warnings_no>
100        for line in open(fname).readlines():
101            try:
102                (pkg, errors_no, warnings_no) = line.split()
103                lintian[pkg] = (int(errors_no), int(warnings_no))
104            except ValueError:
105                continue
106        return lintian
107    
108    # DEHS textual file are line oriented with lines like "field: value"
109    def read_dehs(fname):
110        f = open(fname)
111        for line in f.readlines():
112            yield map(string.strip, line.split(':'))
113        f.close()
114    
115    # read 822 dump of NEW queue content
116    def read_NEW(fname):
117        new_contents = {}
118        for stanza in deb822.Sources.iter_paragraphs(file(os.path.join(dir, 'new.822'))):
119            if stanza.has_key('source') and stanza.has_key('version') and \
120                    stanza.has_key('queue'):
121                # store only the most recent version in NEW (ignore accepted)
122                if stanza['queue'] == 'new' and \
123                        (not new_contents.has_key(stanza['source']) or \
124                         debian_support.version_compare( \
125                                        new_contents[stanza['source']],
126                                        stanza['version']) < 0):
127                    new_contents[stanza['source']] = stanza['version']
128        return new_contents
129    
130    def read_l10n_status(fname):
131        l10n = {}
132        if os.path.exists(fname):
133            f = open(fname)
134            for line in f.readlines():
135                if line.startswith('#'):
136                    continue
137                pkg, version, trans, url, todo = line.rstrip().split()
138                deb_trans, nondeb_trans = trans.strip('()').split(',')
139                l10n[pkg] = {'version': version,
140                             'deb': deb_trans, 'nondeb': nondeb_trans,
141                             'url': url, 'todo': todo}
142            f.close()
143        return l10n
144    
145    # Initialization: fill binary <-> source maps
146  f = open(dir + "/sources.map", "r")  f = open(dir + "/sources.map", "r")
147  while 1:  while 1:
148      line = f.readline();      line = f.readline();
149      if not line: break #eof      if not line: break #eof
150      line = line.strip()      line = line.strip()
151      (binary, source) = line.split(None, 1)      (binary, source) = line.split(None, 1)
152      if not sources.has_key(source):      if not source2binaries.has_key(source):
153          sources[source] = []          source2binaries[source] = []
154      sources[source].append(binary)      source2binaries[source].append(binary)
155        binary2source[binary] = source
156  f.close()  f.close()
157    
158  # Read all the bugs stats  # Read all the bugs stats
# Line 36  while 1: Line 163  while 1:
163      if not line: break #eof      if not line: break #eof
164      line = line.strip()      line = line.strip()
165      (binary, stats) = line.split(None, 1)      (binary, stats) = line.split(None, 1)
166      bugs[binary] = stats.split()      bugs[binary] = [ string.atoi(i) for i in stats.split() ]
167    f.close()
168    
169    srcbugs = {}
170    f = open(dir + "/bugs-src.txt")
171    while 1:
172        line = f.readline()
173        if not line: break #eof
174        line = line.strip()
175        (pkg, stats) = line.split(":", 1)
176        try:
177            srcbugs[pkg] = [ string.atoi(i) for i in stats.replace("(", " ").replace(")", " ").split() ]
178        except:
179            sys.stderr.write("Failed to parse bugs-src.txt stats for %s: %s" % (pkg, stats))
180  f.close()  f.close()
181    
182    gift_bugs = read_bug_summary(os.path.join(dir, 'bugs.gift.txt'))
183    help_bugs = read_bug_summary(os.path.join(dir, 'bugs.help.txt'))
184    
185  # Read all the PTS stats  # Read all the PTS stats
186  pts = {}  pts = {}
187  f = open(dir + "/count.txt")  f = open(dir + "/count.txt")
# Line 52  f.close() Line 195  f.close()
195    
196  # Read the lisf of packages with debcheck problems  # Read the lisf of packages with debcheck problems
197  debcheck = {}  debcheck = {}
198  for dist in ("stable", "testing", "unstable"):  for dist in ("oldstable", "stable", "testing", "unstable"):
199      debcheck[dist] = {}      debcheck[dist] = {}
200      f = open(dir + "/debcheck-" + dist)      f = open(dir + "/debcheck-" + dist)
201      while 1:      while 1:
# Line 74  for dist in ("unstable", "experimental") Line 217  for dist in ("unstable", "experimental")
217              override[dist][source].append(line.strip()[2:])              override[dist][source].append(line.strip()[2:])
218      f.close()      f.close()
219    
220  # Read the list of source packages with debconf templates  # read the package localization status
221  debconf = {}  l10n = read_l10n_status(os.path.join(dir, 'l10n-status.txt'))
 # DISABLED until ddtp.debian.org is setup again  
 #f = open(dir + "/debconf-list")  
 #while 1:  
 #    line = f.readline()  
 #    if not line: break #eof  
 #    line = line.strip()  
 #    debconf[line] = 1;  
 #f.close()  
222    
223  # Read the current signature of other.xml files  # Read the current signature of other.xml files
224  sigs = {}  sigs = {}
# Line 110  if os.path.exists(dir + "/wnpp_rm"): Line 245  if os.path.exists(dir + "/wnpp_rm"):
245      f.close()      f.close()
246    
247  # Read patches information [FG]  # Read patches information [FG]
248  patches = {}  ubuntu_patches = {}
249  # this can be easily inserted into a new update_patches.py if it becomes too  # this can be easily inserted into a new update_patches.py if it becomes too
250  # heavy to parse the file  # heavy to parse the file
251  if os.path.exists(dir + "/patches.ubuntu"):  if os.path.exists(dir + "/patches.ubuntu"):
# Line 122  if os.path.exists(dir + "/patches.ubuntu Line 257  if os.path.exists(dir + "/patches.ubuntu
257          if not r:          if not r:
258              continue              continue
259          version = r.group(1)          version = r.group(1)
260          patches[package] = {}          ubuntu_patches[package] = (version, "http://patches.ubuntu.com/" + rel_url)
         patches[package]['ubuntu'] = (version, "http://patches.ubuntu.com/" + rel_url)  
261      f.close()      f.close()
262    
263  # read low threshold NMU infos  ubuntu_versions = {}
264  def read_low_threshold_nmu(fname):  if os.path.exists(dir + "/versions.ubuntu"):
265      emails = []      f = open(dir + "/versions.ubuntu")
266      if os.path.exists(fname):      for line in f.readlines():
267          f = open(fname)          (package, version) = line.split(' ', 2)
268          devel_php_RE = \          version = version.strip()
269              re.compile(r'http://qa\.debian\.org/developer\.php\?login=([^\s&]+)')          ubuntu_versions[package] = (version, "https://launchpad.net/ubuntu/+source/" + package)
270          word_RE = re.compile(r'^\w+$')      f.close()
271          for line in f.readlines():  
272              match = devel_php_RE.search(line)  ubuntu_bugs = {}
273              while match:    # look for several matches on the same line  if os.path.exists(dir + "/bugs.ubuntu"):
274                  email = None      f = open(dir + "/bugs.ubuntu")
275                  login = match.group(1)      for line in f.readlines():
276                  if word_RE.match(login):          (package, count) = line.split('|', 2)
277                      email = login + '@debian.org'          count = count.strip()
278                  elif login.find('@') >= 0:          ubuntu_bugs[package] = (count, "https://bugs.launchpad.net/ubuntu/+source/" + package)
279                      email = login      f.close()
                 if email:  
                     emails.append(email)  
                 line = line[match.end():]  
                 match = devel_php_RE.search(line)  
         f.close()  
     return emails  
280    
281  # write lowThresholdNmu info to a (global, i.e. not per-package) file  # write lowThresholdNmu info to a (global, i.e. not per-package) file
282  #  #
# Line 163  f.writelines(map(lambda s: "  <email>%s< Line 291  f.writelines(map(lambda s: "  <email>%s<
291  f.write("</emails>\n");  f.write("</emails>\n");
292  f.close()  f.close()
293    
 def read_transitions(fname):  
     f = open(fname)  
     markup = f.read()  
     f.close()  
     yaml = syck.load(markup)  
     packages = {} # maps pkg to the _list_ of transitions they are involved in  
     for id, transition in yaml.iteritems():  
         for pkg in transition['packages']:  
             if not packages.has_key(pkg):  
                 packages[pkg] = []  
             packages[pkg].append(id)  
     return packages  
   
294  # read the list of packages involved in transitions  # read the list of packages involved in transitions
295  transitions = read_transitions(os.path.join(dir, "transitions.yaml"))  transitions = read_transitions(os.path.join(dir, "transitions.yaml"))
296    
297    piuparts = read_piuparts(os.path.join(dir, "piuparts-sid.txt"))
298    
299    new_queue = read_NEW(os.path.join(dir, "new.822"))
300    
301    # read QA lintian info
302    lintian = read_lintian_info(os.path.join(dir, "lintian.qa-list.txt"))
303    
304  # read the list of packages indexed by svnbuildstat.debian.net  # read the list of packages indexed by svnbuildstat.debian.net
305  svnbuildstat = {}  svnbuildstat = {}
306  f = open(os.path.join(dir, "svnbuildstat_list.txt"))  f = open(os.path.join(dir, "svnbuildstat_list.txt"))
# Line 186  for pkgname in map(string.rstrip, f.read Line 308  for pkgname in map(string.rstrip, f.read
308      svnbuildstat[pkgname] = True      svnbuildstat[pkgname] = True
309  f.close()  f.close()
310    
 # DEHS textual file are line oriented with lines like "field: value"  
 def read_dehs(fname):  
     f = open(fname)  
     for line in f.readlines():  
         yield map(string.strip, line.split(':'))  
     f.close()  
   
311  # read info gathered from dehs.alioth.debian.org  # read info gathered from dehs.alioth.debian.org
312  dehs = {}  dehs = {}
313  for pkgname, version in read_dehs(os.path.join(dir, "dehs_out_of_date.txt")):  for pkgname, version in read_dehs(os.path.join(dir, "dehs_out_of_date.txt")):
# Line 204  for pkgname, msg in read_dehs(os.path.jo Line 319  for pkgname, msg in read_dehs(os.path.jo
319          dehs[pkgname] = {}          dehs[pkgname] = {}
320      dehs[pkgname]['error'] = msg      dehs[pkgname]['error'] = msg
321    
322    # read short descriptions
323    shortdescs = read_shortdesc(os.path.join(dir, "shortdesc.txt"))
324    
325  # Create the XML documents  # Create the XML documents
326  while 1:  while 1:
327      line = sys.stdin.readline()      line = sys.stdin.readline()
# Line 212  while 1: Line 330  while 1:
330    
331      doc = implementation.createDocument(None, "other", None)      doc = implementation.createDocument(None, "other", None)
332      root_elt = doc.documentElement      root_elt = doc.documentElement
333        hash = hash_name(pkg)
     hash = pkg[0]  
     if pkg[0:3] == "lib":  
         hash = pkg[0:4]  
334    
335      # Add debcheck availability info      # Add debcheck availability info
336      dc_sig = ""      dc_sig = ""
337      elt = doc.createElement("debcheck")      elt = doc.createElement("debcheck")
338      for dist in ("stable", "testing", "unstable"):      for dist in ("oldstable", "stable", "testing", "unstable"):
339          if debcheck[dist].has_key(pkg):          if debcheck[dist].has_key(pkg):
340              elt.setAttribute(dist, "yes")              elt.setAttribute(dist, "yes")
341              dc_sig += "y"              dc_sig += "y"
# Line 228  while 1: Line 343  while 1:
343              elt.setAttribute(dist, "no")              elt.setAttribute(dist, "no")
344              dc_sig += "n"              dc_sig += "n"
345      root_elt.appendChild(elt)      root_elt.appendChild(elt)
346    
347      # Add debconf templates availibilty info      # Add NEW queue versions, if any
348      if debconf.has_key(pkg):      if new_queue.has_key(pkg):
349          root_elt.setAttribute("debconf", "yes")          root_elt.setAttribute("new_version", new_queue[pkg])
350          dc_sig += "y"          new_queue_sig = 'y'
351      else:      else:
352          root_elt.setAttribute("debconf", "no")          new_queue_sig = 'n'
353          dc_sig += "n"  
   
354      # Get PTS stats      # Get PTS stats
355      elt = doc.createElement("pts")      elt = doc.createElement("pts")
356      elt.setAttribute("count", pts.get(pkg, "0"))      elt.setAttribute("count", pts.get(pkg, "0"))
# Line 244  while 1: Line 358  while 1:
358    
359      # Get BTS stats      # Get BTS stats
360      elt = doc.createElement("bugs")      elt = doc.createElement("bugs")
361      (s_rc, s_normal, s_wishlist, s_fixed, s_patch) = (0,0,0,0,0)      (s_rc, s_rc_m, s_normal, s_normal_m, s_wishlist, s_wishlist_m, s_fixed,
362      binlist = sources.get(pkg, [])              s_fixed_m, s_patch, s_patch_m) = \
363                        srcbugs.get(pkg, [0,0,0,0,0,0,0,0,0,0])
364        binlist = source2binaries.get(pkg, [])
365      binlist.sort()      binlist.sort()
366      subsig = ""      subsig = ""
367      for binary in binlist:      for binary in binlist:
368          sub_elt = doc.createElement("item")          sub_elt = doc.createElement("item")
369          sub_elt.setAttribute("name", binary)          sub_elt.setAttribute("name", binary)
370          (rc, normal, wishlist, fixed, patch) = bugs.get(binary, ["0","0","0","0","0"])          (rc, normal, wishlist, fixed, patch) = bugs.get(binary, [0,0,0,0,0])
371          sub_elt.setAttribute("rc", rc)          sub_elt.setAttribute("rc", "%d" % rc)
372          sub_elt.setAttribute("normal", normal)          sub_elt.setAttribute("normal", "%d" % normal)
373          sub_elt.setAttribute("wishlist", wishlist)          sub_elt.setAttribute("wishlist", "%d" % wishlist)
374          sub_elt.setAttribute("fixed", fixed)          sub_elt.setAttribute("fixed", "%d" % fixed)
375          sub_elt.setAttribute("patch", patch)          sub_elt.setAttribute("patch", "%d" % patch)
         rc = string.atoi(rc)  
         normal = string.atoi(normal)  
         wishlist = string.atoi(wishlist)  
         fixed = string.atoi(fixed)  
         patch = string.atoi(patch)  
376          all = rc + normal + wishlist + fixed          all = rc + normal + wishlist + fixed
377          sub_elt.setAttribute("all", "%d" % all)          sub_elt.setAttribute("all", "%d" % all)
378          elt.appendChild(sub_elt)          elt.appendChild(sub_elt)
# Line 269  while 1: Line 380  while 1:
380              subsig = "%s|%d|%d" % (subsig, all, patch)              subsig = "%s|%d|%d" % (subsig, all, patch)
381          else:          else:
382              subsig = "%d|%d" % (all, patch)              subsig = "%d|%d" % (all, patch)
383          s_rc += rc  
         s_normal += normal  
         s_wishlist += wishlist  
         s_fixed += fixed  
         s_patch += patch  
     if (pkg not in binlist): # Source package needs to be counted too  
         (rc, normal, wishlist, fixed, patch) = bugs.get(pkg, ["0","0","0","0","0"])  
         s_rc += string.atoi(rc)  
         s_normal += string.atoi(normal)  
         s_wishlist += string.atoi(wishlist)  
         s_fixed += string.atoi(fixed)  
         s_patch += string.atoi(patch)  
   
384      elt.setAttribute("rc", "%d" % s_rc)      elt.setAttribute("rc", "%d" % s_rc)
385        if s_rc != s_rc_m:
386            elt.setAttribute("rc_m", "%d" % s_rc_m)
387      elt.setAttribute("normal", "%d" % s_normal)      elt.setAttribute("normal", "%d" % s_normal)
388        if s_normal != s_normal_m:
389            elt.setAttribute("normal_m", "%d" % s_normal_m)
390      elt.setAttribute("wishlist", "%d" % s_wishlist)      elt.setAttribute("wishlist", "%d" % s_wishlist)
391        if s_wishlist != s_wishlist_m:
392            elt.setAttribute("wishlist_m", "%d" % s_wishlist_m)
393      elt.setAttribute("fixed", "%d" % s_fixed)      elt.setAttribute("fixed", "%d" % s_fixed)
394        if s_fixed != s_fixed_m:
395            elt.setAttribute("fixed_m", "%d" % s_fixed_m)
396      elt.setAttribute("patch", "%d" % s_patch)      elt.setAttribute("patch", "%d" % s_patch)
397      elt.setAttribute("all", "%d" % (s_fixed + s_wishlist + s_normal + s_rc))      if s_patch != s_patch_m:
398            elt.setAttribute("patch_m", "%d" % s_patch_m)
399        s_all = s_fixed + s_wishlist + s_normal + s_rc
400        s_all_m = s_fixed_m + s_wishlist_m + s_normal_m + s_rc_m
401        elt.setAttribute("all", "%d" % s_all)
402        if s_all != s_all_m:
403            elt.setAttribute("all_m", "%d" % s_all_m)
404      root_elt.appendChild(elt)      root_elt.appendChild(elt)
405        if gift_bugs.has_key(pkg):
406            s_gift = gift_bugs[pkg]
407        else:
408            s_gift = 0
409        elt.setAttribute("gift", str(s_gift))
410        if help_bugs.has_key(pkg):
411            s_help = help_bugs[pkg]
412        else:
413            s_help = 0
414        elt.setAttribute("help", str(s_help))
415    
416      # Get WNPP information. [PvR]      # Get WNPP information. [PvR]
417      if wnpp.has_key(pkg):      if wnpp.has_key(pkg):
# Line 326  while 1: Line 449  while 1:
449      else:      else:
450          root_elt.setAttribute("override", "no")          root_elt.setAttribute("override", "no")
451    
452      # Add patches informations [FG]      # Add Ubuntu information
453      if patches.has_key(pkg):      if ubuntu_versions.has_key(pkg):
454          elt = doc.createElement("patches")          elt = doc.createElement("ubuntu")
455          patch_sig = ""          (version, url) = ubuntu_versions[pkg]
456          distros = patches[pkg].keys()          ubuntu_sig = "ubuntu/ " + version
457          distros.sort()          elt.setAttribute("version", unicode(version, 'UTF8', 'replace'))
458          for distro in distros:          elt.setAttribute("url", unicode(url, 'UTF8', 'replace'))
459             child = doc.createElement("item")          if ubuntu_bugs.has_key(pkg):
460             (version, url) = patches[pkg][distro]             elt.setAttribute("bugs", "yes")
461             child.setAttribute("distro", unicode(distro, 'UTF8', 'replace'))             elt_bugs = doc.createElement("bugs")
462             child.setAttribute("version", unicode(version, 'UTF8', 'replace'))             (count, url) = ubuntu_bugs[pkg]
463             child.setAttribute("url", unicode(url, 'UTF8', 'replace'))             ubuntu_sig += "ubuntubugs/" + count
464             elt.appendChild(child)             elt_bugs.setAttribute("count", unicode(count, 'UTF8', 'replace'))
465             patch_sig += "%s/%s " % (distro, version)             elt_bugs.setAttribute("url", unicode(url, 'UTF8', 'replace'))
466               elt.appendChild(elt_bugs)
467            if ubuntu_patches.has_key(pkg):
468               elt.setAttribute("patch", "yes")
469               elt_patch = doc.createElement("patch")
470               (version, url) = ubuntu_patches[pkg]
471               ubuntu_sig += "ubuntupatch/" + version
472               elt_patch.setAttribute("version", unicode(version, 'UTF8', 'replace'))
473               elt_patch.setAttribute("url", unicode(url, 'UTF8', 'replace'))
474               elt.appendChild(elt_patch)
475          root_elt.appendChild(elt)          root_elt.appendChild(elt)
476          root_elt.setAttribute("patches", "yes")          root_elt.setAttribute("ubuntu", "yes")
477      else:      else:
478          root_elt.setAttribute("patches", "no")          root_elt.setAttribute("ubuntu", "no")
479          patch_sig = "n"          ubuntu_sig = "n"
480    
481      # Get DEHS information      # Get DEHS information
482      if dehs.has_key(pkg):      if dehs.has_key(pkg):
# Line 370  while 1: Line 502  while 1:
502          root_elt.setAttribute("svnbuildstat", "no")          root_elt.setAttribute("svnbuildstat", "no")
503          svnbuildstat_sig = "n"          svnbuildstat_sig = "n"
504    
505        # add piuparts info
506        if piuparts.has_key(pkg):
507            #elt = doc.createElement("piuparts")
508            #root_elt.appendChild(elt)
509            root_elt.setAttribute("piuparts", "yes")
510            piuparts_sig = "y"
511        else:
512            root_elt.setAttribute("piuparts", "no")
513            piuparts_sig = "n"
514    
515        # add localization info
516        if l10n.has_key(pkg):
517            elt = doc.createElement("i18n")
518            deb, nondeb = l10n[pkg]['deb'], l10n[pkg]['nondeb']
519            elt.setAttribute('deb', deb)
520            elt.setAttribute('nondeb', nondeb)
521            if not (set([deb, nondeb]) <= set(['-', '100'])):
522                # do not show l10n status when fully translated or nothing
523                # is translatable
524                elt.setAttribute('href', l10n[pkg]['url'])
525            if l10n[pkg]['todo'] == '1':
526                elt.setAttribute('todo', 'yes')
527            root_elt.setAttribute("i18n", "yes")
528            root_elt.appendChild(elt)
529            i18n_sig = (deb, nondeb, l10n[pkg]['todo'])
530        else:
531            root_elt.setAttribute("i18n", "no")
532            i18n_sig = ('-','-', 0)
533    
534      # add transitions info      # add transitions info
535      if transitions.has_key(pkg):      if transitions.has_key(pkg):
536          elt = doc.createElement("transitions")          elt = doc.createElement("transitions")
# Line 384  while 1: Line 545  while 1:
545          root_elt.setAttribute("transitions", "no")          root_elt.setAttribute("transitions", "no")
546          transitions_sig = "n"          transitions_sig = "n"
547    
548        # add lintian QA info
549        if lintian.has_key(pkg):
550            (errs, warns) = lintian[pkg]
551            elt = doc.createElement("lintian")
552            elt.setAttribute("errors", str(errs))
553            elt.setAttribute("warnings", str(warns))
554            root_elt.appendChild(elt)
555            root_elt.setAttribute("lintian", "yes")
556            lintian_sig = (errs, warns)
557        else:
558            root_elt.setAttribute("lintian", "no")
559            lintian_sig = (0, 0)
560    
561        # add short descriptions
562        elt = doc.createElement("descriptions")
563        root_elt.appendChild(elt)
564        if shortdescs.has_key(pkg):
565            for package, shortdesc in shortdescs[pkg].iteritems():
566                desc_elt = doc.createElement("shortdesc")
567                elt.appendChild(desc_elt)
568                desc_elt.setAttribute("package", package)
569                desc_text = doc.createTextNode(shortdesc)
570                desc_elt.appendChild(desc_text)
571            shortdesc_sig = str(shortdescs[pkg]).__hash__()
572                # XXX hash(str(...)) does not work: WTF?
573        else:
574            shortdesc_sig = ''.__hash__()
575    
576      # TODO: try to do that signature checking before the creation of XML DOM      # TODO: try to do that signature checking before the creation of XML DOM
577      # Build the sig and check if anything changed      # Build the sig and check if anything changed
578      sig = (pts.get(pkg, "0"), dc_sig, wnpp_sig, override_sig, dehs_sig,      sig = (pts.get(pkg, "0"), dc_sig, wnpp_sig, override_sig, dehs_sig,
579              patch_sig, s_rc, s_normal, s_wishlist, s_fixed, subsig,              ubuntu_sig, s_rc, s_normal, s_wishlist, s_fixed, s_gift, s_help,
580              svnbuildstat_sig, transitions_sig)              subsig, svnbuildstat_sig, transitions_sig, lintian_sig,
581                shortdesc_sig, piuparts_sig, new_queue_sig, i18n_sig)
582      if sigs.has_key(pkg) and sig == sigs[pkg] and \      if sigs.has_key(pkg) and sig == sigs[pkg] and \
583              os.path.isfile("%s/%s/%s/other.xml" % (odir, hash, pkg)):              os.path.isfile("%s/%s/%s/other.xml" % (odir, hash, pkg)):
584          continue          continue
# Line 397  while 1: Line 587  while 1:
587      # Output the data to the XML file      # Output the data to the XML file
588      try:      try:
589          f = open("%s/%s/%s/other.xml" % (odir, hash, pkg), "w")          f = open("%s/%s/%s/other.xml" % (odir, hash, pkg), "w")
590          ext.PrettyPrint(doc, f, "iso-8859-1")          ext.PrettyPrint(doc, f, "utf-8")
591          f.close()          f.close()
592      except:      except Exception, msg:
593          sys.stderr.write("Output problem for " + pkg + "/other.xml\n");          sys.stderr.write("Output problem for " + pkg + "/other.xml (%s)\n" %
594                    msg);
595    
596  # Store the signatures  # Store the signatures
597  f = open(odir + "/other.sigs", "w")  f = open(odir + "/other.sigs", "w")

Legend:
Removed from v.1882  
changed lines
  Added in v.2231

  ViewVC Help
Powered by ViewVC 1.1.5