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."""
17 def __new__ (cls, url, **kw):
18 """ Return the correct sub-class depending on url,
19 pass parsed url parameters to object
22 return super(Store, cls).__new__(cls, url, **kw)
23 (scheme, netloc, path, params, query, fragment) \
24 = urlparse.urlparse(url)
27 cumulus = __import__('cumulus.store.%s' % scheme, globals())
28 subcls = getattr (cumulus.store, scheme).Store
29 obj = super(Store, cls).__new__(subcls, url, **kw)
35 obj.fragment = fragment
38 raise NotImplementedError, "Scheme %s not implemented" % scheme
41 raise NotImplementedError
43 def get(self, type, name):
44 raise NotImplementedError
46 def put(self, type, name, fp):
47 raise NotImplementedError
49 def delete(self, type, name):
50 raise NotImplementedError
52 def stat(self, type, name):
53 raise NotImplementedError
56 """Cache file information stored in this backend.
58 This might make subsequent list or stat calls more efficient, but this
59 function is intended purely as a performance optimization."""
64 """Tier down the connection explicitly if needed
66 Currently needed for sftp to be able to end the program."""