changeset 10:a963acb1713d

add a new handler: MercurialRevision
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 21 Sep 2010 12:01:34 -0700
parents 4dd12cf64c0e
children ba9058605c5a
files setup.py smartopen/handlers.py
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/setup.py
+++ b/setup.py
@@ -32,10 +32,11 @@ setup(name='smartopen',
       [smartopen.locations]
       URL = smartopen.handlers:URL
       GoogleMaps = smartopen.handlers:GoogleMaps
       Wikipedia = smartopen.handlers:Wikipedia
       Google = smartopen.handlers:Google
       Trac = smartopen.handlers:Trac
       Bugzilla = smartopen.handlers:Bugzilla
       FedEx = smartopen.handlers:FedEx
+      MercurialRevision = smartopen.handlers:MercurialRevision
       """,
       )
--- a/smartopen/handlers.py
+++ b/smartopen/handlers.py
@@ -1,9 +1,10 @@
 import address
+import string
 import urllib
 import urllib2
 
 class Location:
     """
     generic class for locations
     """
 
@@ -133,8 +134,19 @@ class FedEx(Location):
         query = self.process(query)
         if len(query) != 12:
             return False
         try:
             int(query)
         except ValueError:
             return False
         return True
+
+class MercurialRevision(Location):
+    def __init__(self):
+        baseurl = 'http://hg.mozilla.org/mozilla-central/rev/'
+        Location.__init__(self, baseurl)
+
+    def test(self, query):
+        query = set(query)
+        if query.issubset(string.digits + 'abcdef'):
+            return True
+        return False