Mercurial > hg > smartopen
comparison smartopen/handlers.py @ 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 | a963acb1713d |
comparison
equal
deleted
inserted
replaced
7:d5343f681ef9 | 8:44950f376e98 |
---|---|
117 Location.__init__(self, googleurl) | 117 Location.__init__(self, googleurl) |
118 | 118 |
119 def process(self, query): | 119 def process(self, query): |
120 return urllib.quote_plus(query) | 120 return urllib.quote_plus(query) |
121 | 121 |
122 class FedEx(Location): | |
123 def __init__(self): | |
124 baseurl = 'http://www.fedex.com/Tracking?cntry_code=us&language=english&tracknumber_list=' | |
125 Location.__init__(self, baseurl) | |
126 | |
127 def process(self, query): | |
128 if query.count(' ') == 2: | |
129 query = ''.join(query.split(' ')) | |
130 return query | |
131 | |
132 def test(self, query): | |
133 query = self.process(query) | |
134 if len(query) != 12: | |
135 return False | |
136 try: | |
137 int(query) | |
138 except ValueError: | |
139 return False | |
140 return True |