Manual 2to3 fixups.
[cumulus.git] / python / cumulus / store / __init__.py
index 1e7d41f..e638bc5 100644 (file)
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-import exceptions, re, urlparse
+from __future__ import division, print_function, unicode_literals
+
+import re
+try:
+    from urllib.parse import urlparse
+except ImportError:
+    from urlparse import urlparse
 
 type_patterns = {
     'checksums': re.compile(r"^snapshot-(.*)\.(\w+)sums$"),
     'segments': re.compile(r"^([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})(\.\S+)?$"),
-    'snapshots': re.compile(r"^snapshot-(.*)\.lbs$")
+    'snapshots': re.compile(r"^snapshot-(.*)\.(cumulus|lbs)$")
 }
 
-class NotFoundError(exceptions.KeyError):
+class NotFoundError(KeyError):
     """Exception thrown when a file is not found in a repository."""
 
     pass
@@ -39,7 +45,7 @@ class Store (object):
         if cls != Store:
             return super(Store, cls).__new__(cls, url, **kw)
         (scheme, netloc, path, params, query, fragment) \
-            = urlparse.urlparse(url)
+            = urlparse(url)
 
         try:
             cumulus = __import__('cumulus.store.%s' % scheme, globals())
@@ -53,24 +59,24 @@ class Store (object):
             obj.fragment = fragment
             return obj
         except ImportError:
-            raise NotImplementedError, "Scheme %s not implemented" % scheme
+            raise NotImplementedError("Scheme %s not implemented" % scheme)
 
-    def list(self, type):
+    def list(self, path):
         raise NotImplementedError
 
-    def get(self, type, name):
+    def get(self, path):
         raise NotImplementedError
 
-    def put(self, type, name, fp):
+    def put(self, path, fp):
         raise NotImplementedError
 
-    def delete(self, type, name):
+    def delete(self, path):
         raise NotImplementedError
 
-    def stat(self, type, name):
+    def stat(self, path):
         raise NotImplementedError
 
-    def scan(self):
+    def scan(self, path):
         """Cache file information stored in this backend.
 
         This might make subsequent list or stat calls more efficient, but this