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