Commit 60e6eff7 by willmcgugan

Work in progress

parent 41f626a4
......@@ -8,7 +8,7 @@ import fs
class InfoFrame(wx.Frame):
def __init__(self, path, desc, info):
wx.Frame.__init__(self, None, -1, style=wx.DEFAULT_FRAME_STYLE, size=(700, 500))
wx.Frame.__init__(self, None, -1, style=wx.DEFAULT_FRAME_STYLE, size=(500, 500))
self.SetTitle("FS Object info - %s (%s)" % (path, desc))
......@@ -20,7 +20,7 @@ class InfoFrame(wx.Frame):
self.list_ctrl.InsertColumn(0, "Key")
self.list_ctrl.InsertColumn(1, "Value")
self.list_ctrl.SetColumnWidth(0, 150)
self.list_ctrl.SetColumnWidth(0, 190)
self.list_ctrl.SetColumnWidth(1, 300)
for key in keys:
......
......@@ -25,6 +25,7 @@ error_msgs = {
"DIR_EXISTS" : "Directory exists (try allow_recreate=True): %(path)s",
"REMOVE_FAILED" : "Unable to remove file: %(path)s",
"REMOVEDIR_FAILED" : "Unable to remove dir: %(path)s",
"GETSIZE_FAILED" : "Unable to retrieve size of resource: %(path)s",
# NoSysPathError
"NO_SYS_PATH" : "No mapping to OS filesytem: %(path)s,",
......@@ -487,7 +488,16 @@ class FS(object):
def getsize(self, path):
return self.getinfo(path)['size']
"""Returns the size (in bytes) of a resource.
path -- A path to the resource
"""
info = self.getinfo(path)
size = info.get('size', None)
if 'size' is None:
raise OperationFailedError("GETSIZE_FAILED", path)
return size
......@@ -576,36 +586,6 @@ class SubFS(FS):
def rename(self, src, dst):
return self.parent.rename(self._delegate(src), self._delegate(dst))
def validatefs(fs):
expected_methods = [ "abspath",
"getsyspath",
"open",
"exists",
"isdir",
"isfile",
"ishidden",
"listdir",
"makedir",
"remove",
"removedir",
"getinfo",
"getsize",
"rename",
]
pad_size = len(max(expected_methods, key=str.__len__))
count = 0
for method_name in sorted(expected_methods):
method = getattr(fs, method_name, None)
if method is None:
print method_name.ljust(pad_size), '?'
else:
print method_name.ljust(pad_size), 'X'
count += 1
print
print "%i out of %i methods" % (count, len(expected_methods))
if __name__ == "__main__":
import osfs
......
......@@ -411,9 +411,7 @@ class MemoryFS(FS):
dir_entry = self._get_dir_entry(path)
if dir_entry is None:
raise ResourceNotFoundError("NO_DIR", path)
paths = dir_entry.contents.keys()
print "Listdir", paths
paths = dir_entry.contents.keys()
return self._listdir_helper(path, paths, wildcard, full, absolute, hidden, dirs_only, files_only)
finally:
self._lock.release()
......
......@@ -140,14 +140,6 @@ class OSFS(FS):
if __name__ == "__main__":
osfs = OSFS("~/projects")
print osfs
for filename in osfs.walkfiles("/", "*.pov"):
print filename
print osfs.getinfo(filename)
validatefs(osfs)
import browsewin
browsewin.browse(osfs)
......
......@@ -247,15 +247,13 @@ class TestOSFS(unittest.TestCase):
info = self.fs.getinfo("info.txt")
self.assertEqual(info['size'], len(test_str))
def test_getsize(self):
test_str = "*"*23
f = self.fs.open("info.txt", 'wb')
f.write(test_str)
f.close()
info = self.fs.getinfo("info.txt")
self.assertEqual(info['size'], len(test_str))
size = self.fs.getsize("info.txt")
self.assertEqual(size, len(test_str))
class TestSubFS(TestOSFS):
......
......@@ -10,7 +10,7 @@ def copy_file(src_fs, src_path, dst_fs, dst_path, chunk_size=1024*16):
dst_fs -- Destination filesystem object
dst_path -- Destination filesystem object
chunk_size -- Size of chunks to move if system copyfile is not available (default 16K)
"""
src_syspath = src_fs.getsyspath(src_path, default="")
......@@ -48,7 +48,4 @@ def get_total_data(count_fs):
"""
total = 0
for f in count_fs.walkfiles(absolute=True):
total += count_fs.getsize(f)
return total
total = sum(count_fs.getsize(f) for f in count_fs.walkfiles(absolute=True))
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