Commit 4b97c220 by rfkelly0

fix handling of callable wildcards in RPCFS

parent 9b689b6b
...@@ -830,8 +830,6 @@ class FS(object): ...@@ -830,8 +830,6 @@ class FS(object):
else: else:
return self.listdir(path, *args, **kwargs) return self.listdir(path, *args, **kwargs)
if search == "breadth":
if wildcard is None: if wildcard is None:
wildcard = lambda f:True wildcard = lambda f:True
elif not callable(wildcard): elif not callable(wildcard):
...@@ -844,6 +842,8 @@ class FS(object): ...@@ -844,6 +842,8 @@ class FS(object):
dir_wildcard_re = re.compile(fnmatch.translate(dir_wildcard)) dir_wildcard_re = re.compile(fnmatch.translate(dir_wildcard))
dir_wildcard = lambda fn:bool (dir_wildcard_re.match(fn)) dir_wildcard = lambda fn:bool (dir_wildcard_re.match(fn))
if search == "breadth":
dirs = [path] dirs = [path]
while dirs: while dirs:
current_path = dirs.pop() current_path = dirs.pop()
......
...@@ -210,9 +210,21 @@ class RPCFS(FS): ...@@ -210,9 +210,21 @@ class RPCFS(FS):
return self.proxy.isfile(path) return self.proxy.isfile(path)
def listdir(self, path="./", wildcard=None, full=False, absolute=False, dirs_only=False, files_only=False): def listdir(self, path="./", wildcard=None, full=False, absolute=False, dirs_only=False, files_only=False):
path = self.encode_path(path) enc_path = self.encode_path(path)
entries = self.proxy.listdir(path,wildcard,full,absolute,dirs_only,files_only) if not callable(wildcard):
return [self.decode_path(e) for e in entries] entries = self.proxy.listdir(enc_path,wildcard,full,absolute,
dirs_only,files_only)
entries = [self.decode_path(e) for e in entries]
else:
entries = self.proxy.listdir(enc_path,None,False,False,
dirs_only,files_only)
entries = [self.decode_path(e) for e in entries]
entries = [e for e in entries if wildcard(e)]
if full:
entries = [relpath(pathjoin(path,e)) for e in entries]
elif absolute:
entries = [abspath(pathjoin(path,e)) for e in entries]
return entries
def makedir(self, path, recursive=False, allow_recreate=False): def makedir(self, path, recursive=False, allow_recreate=False):
path = self.encode_path(path) path = self.encode_path(path)
......
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