Mercurial > hg > smartopen
changeset 8:44950f376e98
add FedEx tracking number handler
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 08 Apr 2010 14:37:48 -0700 |
parents | d5343f681ef9 |
children | 4dd12cf64c0e |
files | setup.py smartopen/handlers.py |
diffstat | 2 files changed, 21 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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 """, )
--- 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