~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/externalbugtracker/bugzilla.py

  • Committer: Curtis Hovey
  • Date: 2011-05-27 21:53:34 UTC
  • mto: This revision was merged to the branch mainline in revision 13136.
  • Revision ID: curtis.hovey@canonical.com-20110527215334-jqlkmt52nnl4bpeh
Moved launchpad.event into registry interfaces.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
    ]
13
13
 
14
14
from email.Utils import parseaddr
 
15
import re
15
16
from httplib import BadStatusLine
16
17
from urllib2 import URLError
17
18
from xml.dom import minidom
18
 
import re
19
 
import string
20
19
import xml.parsers.expat
21
20
import xmlrpclib
22
21
 
60
59
class Bugzilla(ExternalBugTracker):
61
60
    """An ExternalBugTrack for dealing with remote Bugzilla systems."""
62
61
 
63
 
    batch_query_threshold = 0  # Always use the batch method.
 
62
    batch_query_threshold = 0 # Always use the batch method.
64
63
    _test_xmlrpc_proxy = None
65
64
 
66
65
    def __init__(self, baseurl, version=None):
178
177
        # encoding that page is in, and then encode() it into the utf-8
179
178
        # that minidom requires.
180
179
        contents = encoding.guess(contents).encode("utf-8")
181
 
        # Since the string is utf-8 encoded and utf-8 encoded string have the
182
 
        # high bit set for non-ASCII characters, we can now strip out any
183
 
        # ASCII control characters without touching encoded Unicode
184
 
        # characters.
185
 
        bad_chars = ''.join(chr(i) for i in range(0, 32))
186
 
        for char in '\n\r\t':
187
 
            bad_chars = bad_chars.replace(char, '')
188
 
        trans_map = string.maketrans(bad_chars, ' ' * len(bad_chars))
189
 
        contents = contents.translate(trans_map)
190
180
        return minidom.parseString(contents)
191
181
 
192
182
    def _probe_version(self):
499
489
        """See `ExternalBugTracker`."""
500
490
        try:
501
491
            if bug_id not in self.remote_bug_importance:
502
 
                return "Bug %s is not in remote_bug_importance" % bug_id
 
492
                return "Bug %s is not in remote_bug_importance" %(bug_id)
503
493
            return self.remote_bug_importance[bug_id]
504
494
        except:
505
495
            return UNKNOWN_REMOTE_IMPORTANCE