Commit 4f626fc5 by willmcgugan

Added desc method to filesystems that display debugging information regarding file / dir location

parent 4b2f57cb
......@@ -11,7 +11,7 @@ class BrowseFrame(wx.Frame):
def __init__(self, fs):
wx.Frame.__init__(self, None)
wx.Frame.__init__(self, None, size=(1000, 600))
self.fs = fs
self.SetTitle("FS Browser - "+str(fs))
......@@ -20,6 +20,7 @@ class BrowseFrame(wx.Frame):
self.tree.AddColumn("FS", 300)
self.tree.AddColumn("Size", 150)
self.tree.AddColumn("Created", 250)
self.tree.AddColumn("Description", 250)
self.root_id = self.tree.AddRoot('root', data=wx.TreeItemData( {'path':"/", 'expanded':False} ))
rid = self.tree.GetItemData(self.root_id)
......@@ -98,6 +99,8 @@ class BrowseFrame(wx.Frame):
self.tree.SetItemText(new_item, ct.ctime(), 2)
else:
self.tree.SetItemText(new_item, 'unknown', 2)
self.tree.SetItemText(new_item, self.fs.desc(new_path), 3)
item_data['expanded'] = True
self.tree.Expand(item_id)
......
......@@ -14,6 +14,7 @@ error_msgs = {
"INVALID_PATH" : "Path is invalid: %(path)s",
"NO_DIR" : "Directory does not exist: %(path)s",
"NO_FILE" : "No such file: %(path)s",
"NO_RESOURCE" : "No path to: %(path)s",
"LISTDIR_FAILED" : "Unable to get directory listing: %(path)s",
"DELETE_FAILED" : "Unable to delete file: %(path)s",
"NO_SYS_PATH" : "No mapping to OS filesytem: %(path)s,",
......@@ -205,7 +206,21 @@ class FS(object):
if e.code == "NO_FILE":
return NullFile()
raise
def desc(self, path):
if not self.exists(path):
return "No description available"
try:
sys_path = self.getsyspath(path)
except FSError:
return "No description available"
if self.isdir(path):
return "Dir, maps to %s" % sys_path
else:
return "File, maps to %s" % sys_path
def open(self, path, mode="r", buffering=-1, **kwargs):
......
......@@ -175,6 +175,12 @@ class MemoryFS(FS):
raise FSError("NO_SYS_PATH", pathname, msg="This file-system has no syspath")
def desc(self, path):
if self.isdir(path):
return "Dir in memory"
else:
return "File object in memory"
def isdir(self, path):
......
......@@ -45,6 +45,16 @@ class MultiFS(FS):
if fs.exists(path):
return fs
return None
def which(self, path):
for fs in self:
if fs.exists(path):
for fs_name, fs_object in self.fs_lookup.iteritems():
if fs is fs_object:
return fs_name, fs
return None, None
def getsyspath(self, path):
......@@ -54,6 +64,19 @@ class MultiFS(FS):
raise FSError("NO_FILE", path)
def desc(self, path):
if not self.exists(path):
raise FSError("NO_RESOURCE", path)
name, fs = self.which(path)
if name is None:
return ""
return "%s, on %s (%s)" % (fs.desc(path), name, fs)
def open(self, path, mode="r", buffering=-1, **kwargs):
for fs in self:
......
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