# HG changeset patch # User Jeff Hammel # Date 1270762668 25200 # Node ID 44950f376e98b67642bdd139bbac04476cd34a4d # Parent d5343f681ef970e994964fd5651101d5344809a5 add FedEx tracking number handler diff -r d5343f681ef9 -r 44950f376e98 setup.py --- a/setup.py Wed Mar 10 14:49:18 2010 -0500 +++ b/setup.py Thu Apr 08 14:37:48 2010 -0700 @@ -6,7 +6,7 @@ except: description = '' -version = '0.1.3' +version = '0.1.4' setup(name='smartopen', version=version, @@ -36,5 +36,6 @@ Google = smartopen.handlers:Google Trac = smartopen.handlers:Trac Bugzilla = smartopen.handlers:Bugzilla + FedEx = smartopen.handlers:FedEx """, ) diff -r d5343f681ef9 -r 44950f376e98 smartopen/handlers.py --- a/smartopen/handlers.py Wed Mar 10 14:49:18 2010 -0500 +++ b/smartopen/handlers.py Thu Apr 08 14:37:48 2010 -0700 @@ -119,3 +119,22 @@ def process(self, query): return urllib.quote_plus(query) +class FedEx(Location): + def __init__(self): + baseurl = 'http://www.fedex.com/Tracking?cntry_code=us&language=english&tracknumber_list=' + Location.__init__(self, baseurl) + + def process(self, query): + if query.count(' ') == 2: + query = ''.join(query.split(' ')) + return query + + def test(self, query): + query = self.process(query) + if len(query) != 12: + return False + try: + int(query) + except ValueError: + return False + return True