# HG changeset patch # User k0s # Date 1258843776 18000 # Node ID f084e152dd47cbf14c022a53e774d461207bd059 # Parent 10fc4904c10fa3914d25c4c2e3ded7f5253af974 add Trac handler diff -r 10fc4904c10f -r f084e152dd47 setup.py --- a/setup.py Sat Nov 21 17:29:39 2009 -0500 +++ b/setup.py Sat Nov 21 17:49:36 2009 -0500 @@ -30,5 +30,6 @@ GoogleMaps = smartopen.handlers:GoogleMaps Wikipedia = smartopen.handlers:Wikipedia Google = smartopen.handlers:Google + Trac = smartopen.handlers:Trac """, ) diff -r 10fc4904c10f -r f084e152dd47 smartopen.ini --- a/smartopen.ini Sat Nov 21 17:29:39 2009 -0500 +++ b/smartopen.ini Sat Nov 21 17:49:36 2009 -0500 @@ -1,5 +1,5 @@ [DEFAULTS] -handlers = GoogleMaps, Wikipedia, Google +handlers = GoogleMaps, Trac, Wikipedia, Google [Trac] -url = http://trac.openplans.org/trac \ No newline at end of file +baseurl = http://trac.openplans.org/opencore \ No newline at end of file diff -r 10fc4904c10f -r f084e152dd47 smartopen/handlers.py --- a/smartopen/handlers.py Sat Nov 21 17:29:39 2009 -0500 +++ b/smartopen/handlers.py Sat Nov 21 17:49:36 2009 -0500 @@ -57,40 +57,21 @@ return bool(self.process(query)) class Trac(Location): - def __init__(self, url): - self.url = url - - -# TODO: need configuration -# class Revision(Location): -# def __init__(self): -# revision_url = 'http://trac.openplans.org/openplans/changeset/' -# Location.__init__(self, revision_url) - -# def process(self, query): -# return query[1:] + def __init__(self, baseurl): + baseurl = baseurl.strip('/') + '/' + Location.__init__(self, baseurl) -# def test(self, query): -# if query[0] != 'r': -# return False -# return query[1:].isdigit() - -# class TracTicket(Location): -# def __init__(self): -# # url for # data -# number_url = 'http://trac.openplans.org/openplans/ticket/' -# Location.__init__(self, number_url) + def process(self, query): + if query[0] == 'r': + if query[1:].isdigit(): + return 'changeset/' + str(query[1:]) + if query[0] == '#': + if query[1:].isdigit(): + return 'ticket/' + str(query[1:]) -# def process(self, query): -# if query.startswith('#'): -# return query[1:] -# return query - -# def test(self, query): -# query = self.process(query) -# if len(query.split()) != 1: -# return False -# return query.isdigit() + def test(self, query): + return bool(self.process(query)) + class Wikipedia(Location): """try to open the query in wikipedia"""