Implement FTP backend and other code cleanups.
[cumulus.git] / python / cumulus / store / file.py
index 6b16fb6..f343500 100644 (file)
@@ -5,9 +5,11 @@ import cumulus.store
 type_patterns = cumulus.store.type_patterns
 
 class FileStore(cumulus.store.Store):
-    def __init__(self, prefix):
-        while prefix.endswith("/") and prefix != "/": prefix = prefix[:-1]
-        self.prefix = prefix
+    def __init__(self, url, **kw):
+        # if constructor isn't called via factory interpret url as filename
+        if not hasattr (self, 'path'):
+            self.path = url
+        self.prefix = self.path.rstrip("/")
 
     def _get_path(self, type, name):
         return "%s/%s" % (self.prefix, name)
@@ -37,4 +39,6 @@ class FileStore(cumulus.store.Store):
             stat = os.stat(self._get_path(type, name))
             return {'size': stat.st_size}
         except OSError:
-            raise cumulus.store.NotFoundError
+            raise cumulus.store.NotFoundError, (type, name)
+
+Store = FileStore