Commit d9e83470 by willmcgugan

Fixed a few issues that had accumulated in Google Code, bumped the version up to 0.3.0

parent 4b8eb685
......@@ -15,7 +15,7 @@ implementations of this interface such as:
"""
__version__ = "0.2.0a12"
__version__ = "0.3.0"
__author__ = "Will McGugan (will@willmcgugan.com)"
# 'base' imports * from 'path' and 'errors', so their
......
......@@ -108,7 +108,7 @@ class NullFile(object):
try:
from functools import wraps
except ImportError:
wraps = lambda f:f
wraps = lambda f: lambda f: f
def synchronize(func):
......@@ -618,12 +618,12 @@ class FS(object):
"""Returns the size (in bytes) of a resource.
:param path: a path to the resource
:rtype:integer
:rtype: integer
:returns: the size of the file
"""
info = self.getinfo(path)
size = info.get('size', None)
if 'size' is None:
if size is None:
raise OperationFailedError("get size of resource", path)
return size
......@@ -843,7 +843,7 @@ class FS(object):
dir_fs = self.opendir(path)
return dir_fs
def tree(self, max_levels=5):
def printtree(self, max_levels=5):
"""Prints a tree structure of the FS object to the console
:param max_levels: The maximum sub-directories to display, defaults to
......@@ -852,6 +852,7 @@ class FS(object):
"""
from fs.utils import print_fs
print_fs(self, max_levels=max_levels)
tree = printtree
def browse(self):
"""Displays the FS tree in a graphical window (requires wxWidgets)"""
......
......@@ -13,12 +13,7 @@ from fs.path import *
try:
from functools import wraps
except ImportError:
def wraps(func):
def decorator(wfunc):
wfunc.__name__ == func.__name__
wfunc.__doc__ == func.__doc__
wfunc.__module__ == func.__module__
return decorator
wraps = lambda f: lambda f: f
class FSError(Exception):
......
......@@ -26,7 +26,10 @@ from time import sleep
import datetime
import re
from socket import error as socket_error
from functools import wraps
try:
from functools import wraps
except ImportError:
wraps = lambda f: lambda f: f
try:
from cStringIO import StringIO
......
......@@ -151,7 +151,6 @@ class DirEntry(object):
self.created_time = datetime.datetime.now()
self.modified_time = self.created_time
self.accessed_time = self.created_time
self.st_mode = 0700
self.xattrs = {}
......@@ -459,8 +458,7 @@ class MemoryFS(FS):
@synchronize
def _on_close_memory_file(self, open_file, path, value):
filepath, filename = pathsplit(path)
def _on_close_memory_file(self, open_file, path, value):
dir_entry = self._get_dir_entry(path)
if dir_entry is not None and value is not None:
dir_entry.data = value
......@@ -468,8 +466,7 @@ class MemoryFS(FS):
self._unlock_dir_entry(path)
@synchronize
def _on_flush_memory_file(self, path, value):
filepath, filename = pathsplit(path)
def _on_flush_memory_file(self, path, value):
dir_entry = self._get_dir_entry(path)
dir_entry.data = value
......
......@@ -334,6 +334,7 @@ class MountFS(FS):
path = normpath(path)
del self.mount_tree[path]
@synchronize
def settimes(self, path, accessed_time=None, modified_time=None):
path = normpath(path)
fs, mount_path, delegate_path = self._delegate(path)
......
......@@ -55,6 +55,7 @@ directories::
from fs.base import FS, FSError, synchronize
from fs.path import *
from fs import _thread_synchronize_default
from fs.errors import ResourceNotFoundError
class MultiFS(FS):
......
......@@ -533,7 +533,6 @@ class FSTestCases(object):
fs3 = pickle.loads(pickle.dumps(self.fs,-1))
self.assert_(fs3.isfile("test1"))
def test_big_file(self):
chunk_size = 1024 * 256
num_chunks = 4
......@@ -567,7 +566,7 @@ class FSTestCases(object):
"""Test datetime objects are the same to within the timestamp accuracy"""
dts1 = time.mktime(d1.timetuple())
dts2 = time.mktime(d2.timetuple())
return dts1 == dts2
return int(dts1) == int(dts2)
d1 = datetime.datetime(2010, 6, 20, 11, 0, 9, 987699)
d2 = datetime.datetime(2010, 7, 5, 11, 0, 9, 500000)
self.fs.createfile('/dates.txt', 'check dates')
......
......@@ -126,8 +126,7 @@ class ZipFS(FS):
@synchronize
def open(self, path, mode="r", **kwargs):
path = normpath(relpath(path))
self.zip_path = path
path = normpath(relpath(path))
if 'r' in mode:
if self.zip_mode not in 'ra':
......
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