summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.txt6
-rw-r--r--fs/opener.py19
-rw-r--r--fs/osfs/__init__.py10
-rw-r--r--fs/s3fs.py3
-rw-r--r--tox.ini16
5 files changed, 27 insertions, 27 deletions
diff --git a/README.txt b/README.txt
index a68b649..6ecd021 100644
--- a/README.txt
+++ b/README.txt
@@ -14,7 +14,7 @@ Here are a few of the filesystems that can be accessed with Pyfilesystem:
* **FTPFS** access files & directories on an FTP server
* **MemoryFS** access files & directories stored in memory (non-permanent but very fast)
* **MountFS** creates a virtual directory structure built from other filesystems
-* **MultiFS** a virtual filesystem that combines a list of filesystems in to one, and checks them in order when opening files
+* **MultiFS** a virtual filesystem that combines a list of filesystems into one, and checks them in order when opening files
* **OSFS** the native filesystem
* **SFTPFS** access files & directores stored on a Secure FTP server
* **S3FS** access files & directories stored on Amazon S3 storage
@@ -42,7 +42,7 @@ If you later want to display the total size of Python files stored in a zip file
In fact, you could use any of the supported filesystems above, and the code would continue to work as before.
-An alternative to explicity importing the filesystem class you want, is to use an FS opener which opens a filesystem from a URL-like syntax::
+An alternative to explicitly importing the filesystem class you want, is to use an FS opener which opens a filesystem from a URL-like syntax::
from fs.opener import fsopendir
projects_fs = fsopendir('C:/projects')
@@ -64,4 +64,4 @@ http://groups.google.com/group/pyfilesystem-discussion
Further Information
-------------------
-http://www.willmcgugan.com/tag/fs/ \ No newline at end of file
+http://www.willmcgugan.com/tag/fs/
diff --git a/fs/opener.py b/fs/opener.py
index 8500eac..6079226 100644
--- a/fs/opener.py
+++ b/fs/opener.py
@@ -551,9 +551,9 @@ example:
class TempOpener(Opener):
names = ['temp']
- desc = """Creates a temporary filesystem, that is erased on exit.
+ desc = """Creates a temporary filesystem that is erased on exit.
Probably only useful for mounting or serving.
-NB: If you user fscp or fsmv to copy/move files here, you are effectively deleting them!
+NB: If you use fscp or fsmv to copy/move files here, you are effectively deleting them!
example:
* temp://"""
@@ -565,20 +565,24 @@ example:
fs = LazyFS((TempFS,(),{"identifier":fs_name_params}))
return fs, fs_path
+
class S3Opener(Opener):
names = ['s3']
desc = """Opens a filesystem stored on Amazon S3 storage
The environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY should be set"""
+
@classmethod
def get_fs(cls, registry, fs_name, fs_name_params, fs_path, writeable, create_dir):
from fs.s3fs import S3FS
- bucket = fs_path
- path =''
- if '/' in fs_path:
+ username, password, bucket = _parse_credentials(fs_path)
+ path = ''
+ if '/' in bucket:
bucket, path = fs_path.split('/', 1)
- fs = S3FS(bucket)
+ fs = S3FS(bucket,
+ aws_access_key=username or None,
+ aws_secret_key=password or None)
if path:
dirpath, resourcepath = pathsplit(path)
@@ -588,6 +592,7 @@ class S3Opener(Opener):
return fs, path
+
class TahoeOpener(Opener):
names = ['tahoe']
desc = """Opens a Tahoe-LAFS filesystem
@@ -655,7 +660,7 @@ example:
return fs, ''
class HTTPOpener(Opener):
- names = ['http']
+ names = ['http', 'https']
desc = """HTTP file opener. HTTP only supports reading files, and not much else.
example:
diff --git a/fs/osfs/__init__.py b/fs/osfs/__init__.py
index 446ef93..9226b08 100644
--- a/fs/osfs/__init__.py
+++ b/fs/osfs/__init__.py
@@ -115,7 +115,7 @@ class OSFS(OSFSXAttrMixin, OSFSWatchMixin, FS):
"""
super(OSFS, self).__init__(thread_synchronize=thread_synchronize)
- self.encoding = encoding or sys.getfilesystemencoding()
+ self.encoding = encoding or sys.getfilesystemencoding() or 'utf-8'
self.dir_mode = dir_mode
self.use_long_paths = use_long_paths
root_path = os.path.expanduser(os.path.expandvars(root_path))
@@ -182,10 +182,12 @@ class OSFS(OSFSXAttrMixin, OSFSWatchMixin, FS):
:rtype: string
"""
+ # TODO: HAve a closer look at this method
path = os.path.normpath(os.path.abspath(path))
path = self._decode_path(path)
- if len(path) == 6 and not path.endswith("\\"):
- path = path + "\\"
+ if sys.platform == "win32":
+ if len(path) == 6 and not path.endswith("\\"):
+ path = path + "\\"
prefix = os.path.normcase(self.root_path)
if not prefix.endswith(os.path.sep):
prefix += os.path.sep
@@ -228,6 +230,8 @@ class OSFS(OSFSXAttrMixin, OSFSWatchMixin, FS):
def open(self, path, mode='r', buffering=-1, encoding=None, errors=None, newline=None, line_buffering=False, **kwargs):
mode = ''.join(c for c in mode if c in 'rwabt+')
sys_path = self.getsyspath(path)
+ if not encoding and 'b' not in mode:
+ encoding = encoding or 'utf-8'
try:
return io.open(sys_path, mode=mode, buffering=buffering, encoding=encoding, errors=errors, newline=newline)
except EnvironmentError, e:
diff --git a/fs/s3fs.py b/fs/s3fs.py
index 1c8b321..4f51a50 100644
--- a/fs/s3fs.py
+++ b/fs/s3fs.py
@@ -487,7 +487,8 @@ class S3FS(FS):
msg = "Parent directory does not exist: %(path)s"
raise ParentDirectoryMissingError(path, msg=msg)
# Create an empty file representing the directory
- self._sync_set_contents(s3pathD,"")
+ if s3pathD not in ('/', ''):
+ self._sync_set_contents(s3pathD,"")
def remove(self,path):
"""Remove the file at the given path."""
diff --git a/tox.ini b/tox.ini
index 849eea8..b7d5505 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,5 +1,5 @@
[tox]
-envlist = py26,py27,py31,py32,py33,pypy
+envlist = py27,py34,py35,pypy
sitepackages = False
[testenv]
@@ -15,17 +15,7 @@ changedir=.tox
commands = nosetests fs.tests -v \
[]
-
-[testenv:py31]
-commands = nosetests fs.tests -v \
- []
-deps = distribute
- six
- dexml
- nose
- winpdb
-
-[testenv:py32]
+[testenv:py34]
commands = nosetests fs.tests -v \
[]
deps = distribute
@@ -34,7 +24,7 @@ deps = distribute
nose
winpdb
-[testenv:py33]
+[testenv:py35]
commands = nosetests fs.tests -v \
[]
deps = distribute