Package moap :: Package bug :: Module bug
[hide private]
[frames] | no frames]

Source Code for Module moap.bug.bug

 1  # -*- Mode: Python -*- 
 2  # vi:si:et:sw=4:sts=4:ts=4 
 3   
 4  """ 
 5  Base class for bug tracker abstractions. 
 6  """ 
 7   
 8  import sys 
 9   
10  from moap.util import log, util 
11   
12 -def detect(URL):
13 """ 14 Detect which bug tracker is being used at the given URL. 15 16 @returns: an instance of a subclass of L{BugTracker}, or None. 17 """ 18 log.debug('bug', 'detecting bug tracker at %s' % URL) 19 systems = util.getPackageModules('moap.bug', ignore=['bug', ]) 20 21 for s in systems: 22 m = util.namedModule('moap.bug.%s' % s) 23 24 try: 25 ret = m.detect(URL) 26 except AttributeError: 27 sys.stderr.write('moap.bug.%s is missing detect()\n' % s) 28 continue 29 30 if ret: 31 try: 32 o = m.BugClass(ret) 33 except AttributeError: 34 sys.stderr.write('moap.bug.%s is missing BugClass()\n' % s) 35 continue 36 37 return o 38 log.debug('bug', 'did not find %s' % s) 39 40 return None
41
42 -class BugTracker(log.Loggable):
43 - def __init__(self, URL):
44 self.URL = URL
45
46 - def __repr__(self):
47 return '<%s instance at %s>' % (str(self.__class__), self.URL)
48
49 - def getBug(self, id):
50 """ 51 Get the Bug identified by the given id. 52 """ 53 raise NotImplementedError
54
55 - def query(self, queryString):
56 """ 57 Query the database using the given query string. 58 59 @rtype: list of L{Bug} 60 """
61 62
63 -class Bug(log.Loggable):
64 """ 65 I am a bug in a bug tracker. 66 67 @type id: str 68 @type summary: str 69 """ 70 id = None 71 summary = None 72
73 - def __init__(self, id, summary):
74 self.id = id 75 self.summary = summary
76
77 -class NotFoundError(Exception):
78 """ 79 The bug with the given id was not found. 80 """
81 - def __init__(self, id):
82 Exception.__init__(self, id) 83 self.id = id
84