Commit b69bf455 by willmcgugan

Fixed problem recursion on Windows

parent cecb6995
......@@ -29,7 +29,7 @@ class BrowseFrame(wx.Frame):
self.tree.SetItemImage(self.root_id, self.fldridx, wx.TreeItemIcon_Normal)
self.tree.SetItemImage(self.root_id, self.fldropenidx, wx.TreeItemIcon_Expanded)
self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnItemExpanded)
self.Bind(wx.EVT_TREE_ITEM_EXPANDING, self.OnItemExpanding)
self.expand(self.root_id)
......@@ -43,8 +43,7 @@ class BrowseFrame(wx.Frame):
if not self.fs.isdir(path):
return
if item_data['expanded']:
self.tree.Expand(item_id)
if item_data['expanded']:
return
paths = self.fs.listdir(path, absolute=True)
......@@ -76,9 +75,10 @@ class BrowseFrame(wx.Frame):
self.tree.Expand(item_id)
def OnItemExpanded(self, e):
def OnItemExpanding(self, e):
self.expand(e.GetItem())
e.Skip()
def browse(fs):
......
......@@ -233,7 +233,16 @@ class OSFS(FS):
def __init__(self, root_path):
self.root_path = os.path.abspath(os.path.expanduser(root_path))
expanded_path = normpath(os.path.expanduser(root_path))
print expanded_path
if not os.path.exists(expanded_path):
raise FSError("PATH_NOT_EXIST", "Root path does not exist: %(path)s", expanded_path)
if not os.path.isdir(expanded_path):
raise FSError("PATH_NOT_DIR", "Root path is not a directory: %(path)s", expanded_path)
self.root_path = normpath(os.path.abspath(expanded_path))
#print "Root path", self.root_path
def __str__(self):
......@@ -429,19 +438,22 @@ class MountFS(FS):
if __name__ == "__main__":
osfs = OSFS("~/")
print osfs
#print osfs
print_fs(osfs)
#print osfs.listdir("/projects/fs")
sub_fs = osfs.open_dir("projects/")
#sub_fs = osfs.open_dir("projects/")
print sub_fs
#print sub_fs
sub_fs.open('test.txt')
#sub_fs.open('test.txt')
#print sub_fs.listdir(dirs_only=True)
#print sub_fs.listdir()
print_fs(sub_fs, max_levels=2)
#print_fs(sub_fs, max_levels=2)
#for f in osfs.listdir():
# print f
......
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