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)
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