"""
def __init__(self, path):
- self.store = cumulus.store.file.FileStore(path)
+ if path.find(":") >= 0:
+ self.store = cumulus.store.open(path)
+ else:
+ self.store = cumulus.store.file.FileStore(path)
def _classify(self, filename):
for (t, r) in cumulus.store.type_patterns.items():
-import re
+import re, urlparse
type_patterns = {
'checksums': re.compile(r"^snapshot-(.*)\.(\w+)sums$"),
def delete(self, type, name):
raise NotImplementedException
+
+def open(url):
+ (scheme, netloc, path, params, query, fragment) \
+ = urlparse.urlparse(url)
+
+ if scheme == "file":
+ import cumulus.store.file
+ return cumulus.store.file.FileStore(path)
+ elif scheme == "s3":
+ import cumulus.store.s3
+ while path.startswith("/"): path = path[1:]
+ (bucket, path) = path.split("/", 1)
+ return cumulus.store.s3.S3Store(bucket, path)
+ else:
+ raise NotImplementedException
def delete(self, type, name):
self.bucket.delete_key("%s/%s/%s" % (self.prefix, type, name))
+
+ def stat(self, type, name):
+ k = self.bucket.get_key("%s/%s/%s" % (self.prefix, type, name))
+ return {'size': int(k.size)}