X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;ds=sidebyside;f=python%2Fcumulus%2Fstore%2Ffile.py;h=6d23a588d03d527b02457f769ae6c97bad5b02f0;hb=a5f66616b1ec0c38328ad5131bf1c889ccc43659;hp=0998448720d66dfac1786b448221b4468dc76b37;hpb=64bff41cb3ccdd60e767a5bb9ed8525d2dda1966;p=cumulus.git diff --git a/python/cumulus/store/file.py b/python/cumulus/store/file.py index 0998448..6d23a58 100644 --- a/python/cumulus/store/file.py +++ b/python/cumulus/store/file.py @@ -29,34 +29,33 @@ class FileStore(cumulus.store.Store): self.path = url self.prefix = self.path.rstrip("/") - def _get_path(self, type, name): - return "%s/%s" % (self.prefix, name) - - def list(self, type): - files = os.listdir(self.prefix) - return (f for f in files if type_patterns[type].match(f)) + def list(self, subdir): + try: + return os.listdir(os.path.join(self.prefix, subdir)) + except OSError: + raise cumulus.store.NotFoundError(subdir) - def get(self, type, name): - k = self._get_path(type, name) - return open(k, 'rb') + def get(self, path): + try: + return open(os.path.join(self.prefix, path), 'rb') + except IOError: + raise cumulus.store.NotFoundError(path) - def put(self, type, name, fp): - k = self._get_path(type, name) - out = open(k, 'wb') + def put(self, path, fp): + out = open(os.path.join(self.prefix, path), 'wb') buf = fp.read(4096) while len(buf) > 0: out.write(buf) buf = fp.read(4096) - def delete(self, type, name): - k = self._get_path(type, name) - os.unlink(k) + def delete(self, path): + os.unlink(os.path.join(self.prefix, path)) - def stat(self, type, name): + def stat(self, path): try: - stat = os.stat(self._get_path(type, name)) + stat = os.stat(os.path.join(self.prefix, path)) return {'size': stat.st_size} except OSError: - raise cumulus.store.NotFoundError, (type, name) + raise cumulus.store.NotFoundError(path) Store = FileStore