Commit c638a2e9 by willmcgugan

Opener fixes

parent 929c9603
......@@ -9,6 +9,7 @@ from fs.base import FS
from fs.path import normpath
from fs.errors import ResourceNotFoundError, UnsupportedError
from urllib2 import urlopen, URLError
from fs.filelike import FileWrapper
class HTTPFS(FS):
......@@ -20,6 +21,9 @@ class HTTPFS(FS):
"""
_meta = {'read_only':True,
'network':True,}
def __init__(self, url):
"""
......@@ -46,7 +50,7 @@ class HTTPFS(FS):
except OSError, e:
raise ResourceNotFoundError(path, details=e)
return f
return FileWrapper(f)
def exists(self, path):
return self.isfile(path)
......
......@@ -62,11 +62,10 @@ you can always access them directly.
"""
from fs.base import FS, FSError, synchronize
from fs.base import FS, synchronize
from fs.path import *
from fs.errors import *
from fs import _thread_synchronize_default
from fs.errors import ResourceNotFoundError
class MultiFS(FS):
......@@ -234,7 +233,7 @@ class MultiFS(FS):
for fs in self:
try:
paths += fs.listdir(path, *args, **kwargs)
except FSError, e:
except FSError:
pass
return list(set(paths))
......@@ -254,16 +253,14 @@ class MultiFS(FS):
@synchronize
def rename(self, src, dst):
if self.writefs is None:
raise OperationFailedError('rename', path=path, msg="No writeable FS set")
self.writefs.rename(src, dst)
raise ResourceNotFoundError(path)
raise OperationFailedError('rename', path=src, msg="No writeable FS set")
self.writefs.rename(src, dst)
@synchronize
def settimes(self, path, accessed_time=None, modified_time=None):
if self.writefs is None:
raise OperationFailedError('settimes', path=path, msg="No writeable FS set")
self.writefs.settimes(path, accessed_time, modified_time)
raise ResourceNotFoundError(path)
self.writefs.settimes(path, accessed_time, modified_time)
@synchronize
def getinfo(self, path):
......
......@@ -231,7 +231,8 @@ class OpenerRegistry(object):
fs_path = join(fs_path, path)
if create_dir and fs_path:
fs.makedir(fs_path, allow_recreate=True)
if not fs.getmeta('read_only', False):
fs.makedir(fs_path, allow_recreate=True)
pathname, resourcename = pathsplit(fs_path or '')
if pathname and resourcename:
......@@ -659,7 +660,7 @@ example:
def get_fs(cls, registry, fs_name, fs_name_params, fs_path, writeable, create_dir):
from fs.httpfs import HTTPFS
if '/' in fs_path:
dirname, resourcename = fs_path.rsplit('/')
dirname, resourcename = fs_path.rsplit('/', 1)
else:
dirname = fs_path
resourcename = ''
......@@ -796,7 +797,7 @@ example:
mount_fs = MountFS()
for mount_point, mount_path in cfg.items(section):
mount_fs.mount(mount_point, registry.opendir(mount_path))
mount_fs.mount(mount_point, registry.opendir(mount_path, create_dir=create_dir))
return mount_fs, ''
......@@ -832,7 +833,7 @@ example:
multi_fs = MultiFS()
for name, fs_url in cfg.items(section):
multi_fs.addfs(name, registry.opendir(fs_url))
multi_fs.addfs(name, registry.opendir(fs_url, create_dir=create_dir))
return multi_fs, ''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment