summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwillmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f>2008-07-21 09:23:05 +0000
committerwillmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f>2008-07-21 09:23:05 +0000
commitb69bf455faad3f34bdcc58803817fc54ecf0122a (patch)
treea52fdbda22a971984b884b8a6adf672d2c889f47
parentcecb6995419559e7a0812ab5b7518e51d18ceefe (diff)
downloadpyfilesystem-git-b69bf455faad3f34bdcc58803817fc54ecf0122a.tar.gz
Fixed problem recursion on Windows
-rw-r--r--fs/browsewin.py8
-rw-r--r--fs/fs.py22
2 files changed, 21 insertions, 9 deletions
diff --git a/fs/browsewin.py b/fs/browsewin.py
index 5faa435..8c3c2da 100644
--- a/fs/browsewin.py
+++ b/fs/browsewin.py
@@ -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):
diff --git a/fs/fs.py b/fs/fs.py
index 1959fb0..984f85b 100644
--- a/fs/fs.py
+++ b/fs/fs.py
@@ -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