~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).

# pylint: disable-msg=W0401

"""__init__ module for the externalbugtracker package."""

__metaclass__ = type
__all__ = [
    'BATCH_SIZE_UNLIMITED',
    'BugNotFound',
    'BugTrackerConnectError',
    'BugWatchUpdateError',
    'BugWatchUpdateWarning',
    'Bugzilla',
    'DebBugs',
    'DebBugsDatabaseNotFound',
    'ExternalBugTracker',
    'InvalidBugId',
    'LookupTree',
    'Mantis',
    'MantisLoginHandler',
    'PrivateRemoteBug',
    'RequestTracker',
    'Roundup',
    'SourceForge',
    'Trac',
    'UnknownBugTrackerTypeError',
    'UnknownRemoteStatusError',
    'UnparsableBugData',
    'UnparsableBugTrackerVersion',
    'UnsupportedBugTrackerVersion',
    'get_external_bugtracker',
    ]

from lp.bugs.externalbugtracker.base import *
from lp.bugs.externalbugtracker.bugzilla import *
from lp.bugs.externalbugtracker.debbugs import *
from lp.bugs.externalbugtracker.mantis import *
from lp.bugs.externalbugtracker.roundup import *
from lp.bugs.externalbugtracker.rt import *
from lp.bugs.externalbugtracker.sourceforge import *
from lp.bugs.externalbugtracker.trac import *
from lp.bugs.interfaces.bugtracker import BugTrackerType


BUG_TRACKER_CLASSES = {
    BugTrackerType.BUGZILLA: Bugzilla,
    BugTrackerType.DEBBUGS: DebBugs,
    BugTrackerType.MANTIS: Mantis,
    BugTrackerType.TRAC: Trac,
    BugTrackerType.ROUNDUP: Roundup,
    BugTrackerType.RT: RequestTracker,
    BugTrackerType.SOURCEFORGE: SourceForge,
    }


def get_external_bugtracker(bugtracker):
    """Return an `ExternalBugTracker` for bugtracker."""
    bugtrackertype = bugtracker.bugtrackertype
    bugtracker_class = BUG_TRACKER_CLASSES.get(bugtracker.bugtrackertype)
    if bugtracker_class is not None:
        return bugtracker_class(bugtracker.baseurl)
    else:
        raise UnknownBugTrackerTypeError(bugtrackertype.name,
            bugtracker.name)