1 import os, sys, tempfile
5 type_patterns = cumulus.store.type_patterns
7 class FileStore(cumulus.store.Store):
8 def __init__(self, prefix):
9 while prefix.endswith("/") and prefix != "/": prefix = prefix[:-1]
12 def _get_path(self, type, name):
13 return "%s/%s" % (self.prefix, name)
16 files = os.listdir(self.prefix)
17 return (f for f in files if type_patterns[type].match(f))
19 def get(self, type, name):
20 k = self._get_path(type, name)
23 def put(self, type, name, fp):
24 k = self._get_path(type, name)
31 def delete(self, type, name):
32 k = self._get_path(type, name)
35 def stat(self, type, name):
37 stat = os.stat(self._get_path(type, name))
38 return {'size': stat.st_size}
40 raise cumulus.store.NotFoundError