X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=python%2Fcumulus%2Fstore%2F__init__.py;h=35de0ee153ed57187f83a7d7ebf48b7ebee5f51a;hb=92488d46a0deca6d031d07852c3b79214280ab6d;hp=5ebf0d79e30a20a7c7e4b9a6b7cded6ae2014481;hpb=8bff41ddef78fa851b09d141c93bdf387abc1dee;p=cumulus.git diff --git a/python/cumulus/store/__init__.py b/python/cumulus/store/__init__.py index 5ebf0d7..35de0ee 100644 --- a/python/cumulus/store/__init__.py +++ b/python/cumulus/store/__init__.py @@ -1,4 +1,4 @@ -import re +import exceptions, re, urlparse type_patterns = { 'checksums': re.compile(r"^snapshot-(.*)\.(\w+)sums$"), @@ -6,6 +6,11 @@ type_patterns = { 'snapshots': re.compile(r"^snapshot-(.*)\.lbs$") } +class NotFoundError(exceptions.KeyError): + """Exception thrown when a file is not found in a repository.""" + + pass + class Store: """Base class for all cumulus storage backends.""" @@ -20,3 +25,29 @@ class Store: def delete(self, type, name): raise NotImplementedException + + def stat(self, type, name): + raise NotImplementedException + + def scan(self): + """Cache file information stored in this backend. + + This might make subsequent list or stat calls more efficient, but this + function is intended purely as a performance optimization.""" + + pass + +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