1 # vim:set encoding=utf-8:
2 ###############################################################################
4 # © 2007 Christoph Berg <myon@debian.org>
6 # © 2006 Sanghyeon Seo <sanxiyn@gmail.com>
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 # 3. Neither the name of the University nor the names of its contributors
17 # may be used to endorse or promote products derived from this software
18 # without specific prior written permission.
20 # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 ###############################################################################
33 import urllib, urlparse, cgi
35 from BeautifulSoup import BeautifulSoup
36 from __init__ import *
38 # <tr><td nowrap><b>State:</b></td>
39 # <td><tt>open</tt></td></tr>
41 def parse_table(soup, key):
42 cell = soup.firstText(key).findParent('td')
43 return cell.findNextSibling('td').first('tt').string
45 # Cookie: gnatsweb-global=email&cb%40df7cb.de&database&mutt&Submitter-Id&any&columns&Notify-List%20Category%20Synopsis%20Confidential%20Severity%20Priority%20Responsible%20State%20Keywords%20Date-Required%20Class%20Submitter-Id%20Arrival-Date%20Closed-Date%20Last-Modified%20Originator%20Release; gnatsweb-db-mutt=password&g%60vft&user&guest
48 def __init__(self, uri, id):
49 soup = BeautifulSoup(wget(uri, "cookies.txt"))
51 self.id = id or failwith(uri, "Gnats: no id")
52 self.status = parse_table(soup, 'State:') or failwith(uri, "Gnats: no status")
53 self.resolution = None
55 class RemoteGnats(RemoteBts):
56 def __init__(self, cnf):
57 bugre = r'^%(uri)s/([0-9]+)$'
58 urifmt = '%(uri)s/%(id)s'
59 RemoteBts.__init__(self, cnf, bugre, urifmt, GnatsData)
61 def isClosing(self, status, resolution):
62 return status in ('closed',)
64 def isWontfix(self, status, resolution):
65 return status in ('suspended',)
67 RemoteBts.register('gnats', RemoteGnats)