Commit db7cbe5e by willmcgugan

Fix to workaround issue sending callables over xmlrpc

parent 451b1d6c
...@@ -791,7 +791,7 @@ class FS(object): ...@@ -791,7 +791,7 @@ class FS(object):
:rtype: an FS object :rtype: an FS object
""" """
from fs.wrapfs.subfs import SubFS from fs.wrapfs.subfs import SubFS
if not self.exists(path): if not self.exists(path):
raise ResourceNotFoundError(path) raise ResourceNotFoundError(path)
...@@ -819,19 +819,7 @@ class FS(object): ...@@ -819,19 +819,7 @@ class FS(object):
:param ignore_errors: ignore any errors reading the directory :param ignore_errors: ignore any errors reading the directory
""" """
if wildcard is None:
wildcard = lambda f:True
elif not callable(wildcard):
wildcard_re = re.compile(fnmatch.translate(wildcard))
wildcard = lambda fn:bool (wildcard_re.match(fn))
if dir_wildcard is None:
dir_wildcard = lambda f:True
elif not callable(dir_wildcard):
dir_wildcard_re = re.compile(fnmatch.translate(dir_wildcard))
dir_wildcard = lambda fn:bool (dir_wildcard_re.match(fn))
def listdir(path, *args, **kwargs): def listdir(path, *args, **kwargs):
if ignore_errors: if ignore_errors:
...@@ -844,6 +832,18 @@ class FS(object): ...@@ -844,6 +832,18 @@ class FS(object):
if search == "breadth": if search == "breadth":
if wildcard is None:
wildcard = lambda f:True
elif not callable(wildcard):
wildcard_re = re.compile(fnmatch.translate(wildcard))
wildcard = lambda fn:bool (wildcard_re.match(fn))
if dir_wildcard is None:
dir_wildcard = lambda f:True
elif not callable(dir_wildcard):
dir_wildcard_re = re.compile(fnmatch.translate(dir_wildcard))
dir_wildcard = lambda fn:bool (dir_wildcard_re.match(fn))
dirs = [path] dirs = [path]
while dirs: while dirs:
current_path = dirs.pop() current_path = dirs.pop()
...@@ -873,7 +873,7 @@ class FS(object): ...@@ -873,7 +873,7 @@ class FS(object):
except ResourceNotFoundError: except ResourceNotFoundError:
# Could happen if another thread / process deletes something whilst we are walking # Could happen if another thread / process deletes something whilst we are walking
pass pass
yield (recurse_path, self.listdir(recurse_path, wildcard=wildcard, files_only=True)) yield (recurse_path, listdir(recurse_path, wildcard=wildcard, files_only=True))
for p in recurse(path): for p in recurse(path):
yield p yield p
...@@ -1230,3 +1230,5 @@ def flags_to_mode(flags): ...@@ -1230,3 +1230,5 @@ def flags_to_mode(flags):
if flags & os.O_EXCL: if flags & os.O_EXCL:
mode += "x" mode += "x"
return mode return mode
\ No newline at end of file
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