1 import exceptions, re, urlparse
4 'checksums': re.compile(r"^snapshot-(.*)\.(\w+)sums$"),
5 '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+)?$"),
6 'snapshots': re.compile(r"^snapshot-(.*)\.lbs$")
9 class NotFoundError(exceptions.KeyError):
10 """Exception thrown when a file is not found in a repository."""
15 """Base class for all cumulus storage backends."""
18 raise NotImplementedException
20 def get(self, type, name):
21 raise NotImplementedException
23 def put(self, type, name, fp):
24 raise NotImplementedException
26 def delete(self, type, name):
27 raise NotImplementedException
29 def stat(self, type, name):
30 raise NotImplementedException
33 """Cache file information stored in this backend.
35 This might make subsequent list or stat calls more efficient, but this
36 function is intended purely as a performance optimization."""
41 (scheme, netloc, path, params, query, fragment) \
42 = urlparse.urlparse(url)
45 import cumulus.store.file
46 return cumulus.store.file.FileStore(path)
48 import cumulus.store.s3
49 while path.startswith("/"): path = path[1:]
50 (bucket, path) = path.split("/", 1)
51 return cumulus.store.s3.S3Store(bucket, path)
53 raise NotImplementedException