Commit 1865b55d by willmcgugan

Added depth first search for the walk method, added a number of docstrings.

parent a797dfb3
......@@ -405,13 +405,13 @@ class MemoryFS(FS):
finally:
self._lock.release()
def listdir(self, path="/", wildcard=None, full=False, absolute=False, hidden=False, dirs_only=False, files_only=False):
def listdir(self, path="/", wildcard=None, full=False, absolute=False, hidden=True, dirs_only=False, files_only=False):
self._lock.acquire()
try:
dir_entry = self._get_dir_entry(path)
if dir_entry is None:
raise ResourceNotFoundError("NO_DIR", path)
paths = dir_entry.contents.keys()
paths = dir_entry.contents.keys()
return self._listdir_helper(path, paths, wildcard, full, absolute, hidden, dirs_only, files_only)
finally:
self._lock.release()
......
......@@ -82,7 +82,7 @@ class MountFS(FS):
finally:
self._lock.release()
def listdir(self, path="/", wildcard=None, full=False, absolute=False, hidden=False, dirs_only=False, files_only=False):
def listdir(self, path="/", wildcard=None, full=False, absolute=False, hidden=True, dirs_only=False, files_only=False):
self._lock.acquire()
try:
......
......@@ -96,14 +96,13 @@ class MultiFS(FS):
finally:
self._lock.release()
def getsyspath(self, path):
def getsyspath(self, path, allow_none=False):
self._lock.acquire()
try:
fs = self._delegate_search(path)
if fs is not None:
return fs.getsyspath(path)
raise ResourceNotFoundError("NO_FILE", path)
return fs.getsyspath(path, allow_none)
raise ResourceNotFoundError("NO_RESOURCE", path)
finally:
self._lock.release()
......@@ -111,7 +110,7 @@ class MultiFS(FS):
self._lock.acquire()
try:
if not self.exists(path):
raise FSError("NO_RESOURCE", path)
raise ResourceNotFoundError("NO_RESOURCE", path)
name, fs = self.which(path)
if name is None:
......
......@@ -19,7 +19,7 @@ class OSFS(FS):
def __str__(self):
return "<OSFS \"%s\">" % self.root_path
def getsyspath(self, path, default=None):
def getsyspath(self, path, allow_none=False):
sys_path = os.path.join(self.root_path, makerelative(self._resolve(path)))
return sys_path
......@@ -127,7 +127,6 @@ class OSFS(FS):
def getsize(self, path):
sys_path = self.getsyspath(path)
try:
stats = os.stat(sys_path)
except OSError, e:
......@@ -140,6 +139,11 @@ class OSFS(FS):
if __name__ == "__main__":
osfs = OSFS("~/projects")
for p in osfs.walk("tagging-trunk", search='depth'):
print p
import browsewin
browsewin.browse(osfs)
......
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