X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=python%2Fcumulus%2Fstore%2Ffile.py;h=f343500666aa0c17367345be22072c7b4b1200d4;hb=76ce8210bee6f9c2dbefab56873a9b2847d92a13;hp=6034835c276ee15d7ae8bcd1f9398a7e56578011;hpb=f51789bfa9d0f6f9826b72f3c32ff89307ec3dc6;p=cumulus.git diff --git a/python/cumulus/store/file.py b/python/cumulus/store/file.py index 6034835..f343500 100644 --- a/python/cumulus/store/file.py +++ b/python/cumulus/store/file.py @@ -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) @@ -33,5 +35,10 @@ class FileStore(cumulus.store.Store): os.unlink(k) def stat(self, type, name): - stat = os.stat(self._get_path(type, name)) - return {'size': stat.st_size} + try: + stat = os.stat(self._get_path(type, name)) + return {'size': stat.st_size} + except OSError: + raise cumulus.store.NotFoundError, (type, name) + +Store = FileStore