Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pyfs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pyfs
Commits
4ae6f3a3
Commit
4ae6f3a3
authored
Mar 07, 2011
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes of some errors/warnings reported by PyDev and inline documentation
parent
69ab86f7
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
83 additions
and
98 deletions
+83
-98
fs/base.py
+22
-25
fs/ftpfs.py
+3
-7
fs/httpfs.py
+2
-3
fs/mountfs.py
+39
-39
fs/path.py
+4
-4
fs/remote.py
+3
-6
fs/s3fs.py
+1
-4
fs/sftpfs.py
+2
-2
fs/utils.py
+3
-4
fs/watch.py
+2
-2
fs/zipfs.py
+2
-2
No files found.
fs/base.py
View file @
4ae6f3a3
...
...
@@ -8,6 +8,8 @@ Instances of FS represent a filesystem containing files and directories
that can be queried and manipulated. To implement a new kind of filesystem,
start by sublcassing the base FS class.
For more information regarding implementing a working PyFilesystem interface, see :ref:`implementers`.
"""
__all__
=
[
'DummyLock'
,
...
...
@@ -58,7 +60,7 @@ class DummyLock(object):
def
silence_fserrors
(
f
,
*
args
,
**
kwargs
):
"""Perform a function call and return
None if FSError
is thrown
"""Perform a function call and return
``None`` if an :class:`fs.errors.FSError`
is thrown
:param f: Function to call
:param args: Parameters to f
...
...
@@ -79,7 +81,7 @@ class NoDefaultMeta(object):
class
NullFile
(
object
):
"""A NullFile is a file object that has no functionality.
Null files are returned by the
'safeopen'
method in FS objects when the
Null files are returned by the
:meth:`fs.base.FS.safeopen`
method in FS objects when the
file doesn't exist. This can simplify code by negating the need to check
if a file exists, or handling exceptions.
...
...
@@ -172,9 +174,9 @@ class FS(object):
ignore this value.
:param enabled: If True the implementation is permitted to aggressively cache directory
structure / file information. Caching such information
speeds up most
operations,
structure / file information. Caching such information
can speed up many
operations,
particularly for network based filesystems. The downside of caching is that
changes made to directories or files outside of this interface may not be picked up.
changes made to directories or files outside of this interface may not be picked up
immediately
.
"""
pass
...
...
@@ -231,21 +233,18 @@ class FS(object):
* *case_insensitive_paths* True if the file system ignores the case of paths
* *atomic.makedir* True if making a directory is an atomic operation
* *atomic.rename* True if rename is an atomic operation, (and not implemented as a copy followed by a delete)
* *atomic.setcontents* True if the implementation supports setting the contents of a file as an atomic operation (without opening a file)
The following are less common:
* *atomic.setcontents* True if the implementation supports setting the contents of a file as an atomic operation (without opening a file)
* *free_space* The free space (in bytes) available on the file system
* *total_space* The total space (in bytes) available on the file system
FS implementations may expose non-generic meta data through a self-named namespace. e.g.
'somefs.some_meta'
FS implementations may expose non-generic meta data through a self-named namespace. e.g.
``somefs.some_meta``
Since no meta value is guaranteed to exist, it is advisable to always supply a
default value to `
getmeta
`.
default value to `
`getmeta`
`.
:param meta_name: The name of the meta value to retrieve
:param default: An option default to return, if the meta value isn't present
:raises
NoMetaError
: If specified meta value is not present, and there is no default
:raises
`fs.errors.NoMetaError`
: If specified meta value is not present, and there is no default
"""
if
meta_name
not
in
self
.
_meta
:
...
...
@@ -278,7 +277,7 @@ class FS(object):
:param allow_none: if True, this method will return None when there is no system path,
rather than raising NoSysPathError
:type allow_none: bool
:raises
NoSysPathError
: if the path does not map on to a system path, and allow_none is set to False (default)
:raises
`fs.errors.NoSysPathError`
: if the path does not map on to a system path, and allow_none is set to False (default)
:rtype: unicode
"""
...
...
@@ -300,14 +299,14 @@ class FS(object):
"""Returns a url that corresponds to the given path, if one exists.
If the path does not have an equivalent URL form (and allow_none is False)
then a
NoPathURLError
exception is thrown. Otherwise the URL will be
then a
:class:`~fs.errors.NoPathURLError`
exception is thrown. Otherwise the URL will be
returns as an unicode string.
:param path: a path within the filesystem
:param allow_none: if true, this method can return None if there is no
URL form of the given path
:type allow_none: bool
:raises
NoPathURLError
: If no URL form exists, and allow_none is False (the default)
:raises
`fs.errors.NoPathURLError`
: If no URL form exists, and allow_none is False (the default)
:rtype: unicode
"""
...
...
@@ -341,7 +340,7 @@ class FS(object):
def
safeopen
(
self
,
path
,
mode
=
"r"
,
**
kwargs
):
"""Like :py:meth:`~fs.base.FS.open`, but returns a :py:class:`~fs.base.NullFile` if the file could not be opened.
A
NullFile
is a dummy file which has all the methods of a file-like object,
A
``NullFile``
is a dummy file which has all the methods of a file-like object,
but contains no data.
:param path: a path to file that should be opened
...
...
@@ -415,7 +414,7 @@ class FS(object):
:rtype: iterable of paths
:raises `fs.errors.ResourceNotFoundError`: if the path is not found
:raises `fs.err
ror
.ResourceInvalidError`: if the path exists, but is not a directory
:raises `fs.err
ors
.ResourceInvalidError`: if the path exists, but is not a directory
"""
raise
UnsupportedError
(
"list directory"
)
...
...
@@ -707,7 +706,7 @@ class FS(object):
error_callback
=
None
):
"""Create a new file from a string or file-like object asynchronously
This method returns a `
threading.Event` object. Call the `wait
` method on the event object
This method returns a `
`threading.Event`` object. Call the ``wait`
` method on the event object
to block until all data has been written, or simply ignore it.
:param path: a path of the file to create
...
...
@@ -770,7 +769,7 @@ class FS(object):
"""Creates an empty file if it doesn't exist
:param path: path to the file to create
:param wipe:
I
f True, the contents of the file will be erased
:param wipe:
i
f True, the contents of the file will be erased
"""
if
not
wipe
and
self
.
isfile
(
path
):
...
...
@@ -788,12 +787,10 @@ class FS(object):
"""Opens a directory and returns a FS object representing its contents.
:param path: path to directory to open
:rtype:
A
n FS object
:rtype:
a
n FS object
"""
#if path in ('', '/'):
# return self
from
fs.wrapfs.subfs
import
SubFS
if
not
self
.
exists
(
path
):
raise
ResourceNotFoundError
(
path
)
...
...
@@ -816,8 +813,8 @@ class FS(object):
:type dir_wildcard: a string containing a wildcard (e.g. `*.txt`) or a callable that takes the directory name and returns a boolean
:param search: a string dentifying the method used to walk the directories. There are two such methods:
*
"breadth"
yields paths in the top directories first
*
"depth"
yields the deepest paths first
*
``"breadth"``
yields paths in the top directories first
*
``"depth"``
yields the deepest paths first
:param ignore_errors: ignore any errors reading the directory
...
...
@@ -1184,7 +1181,7 @@ class FS(object):
:param path: A path on this filesystem
:param read_only: If True, the mmap may not be modified
:param copy: If False then changes wont be written back to the file
:raises
NoMMapError
: Only paths that have a syspath can be opened as a mmap
:raises
`fs.errors.NoMMapError`
: Only paths that have a syspath can be opened as a mmap
"""
syspath
=
self
.
getsyspath
(
path
,
allow_none
=
True
)
...
...
fs/ftpfs.py
View file @
4ae6f3a3
...
...
@@ -12,7 +12,6 @@ import fs
from
fs.base
import
*
from
fs.errors
import
*
from
fs.path
import
pathsplit
,
abspath
,
dirname
,
recursepath
,
normpath
,
pathjoin
,
isbase
from
fs.remote
import
RemoteFileBuffer
from
ftplib
import
FTP
,
error_perm
,
error_temp
,
error_proto
,
error_reply
...
...
@@ -22,9 +21,8 @@ except ImportError:
_GLOBAL_DEFAULT_TIMEOUT
=
object
()
import
threading
from
time
import
sleep
import
datetime
import
re
from
socket
import
error
as
socket_error
from
fs.local_functools
import
wraps
...
...
@@ -34,7 +32,6 @@ except ImportError:
from
StringIO
import
StringIO
import
time
import
sys
# -----------------------------------------------
...
...
@@ -918,8 +915,7 @@ class FTPFS(FS):
if
not
paths
:
self
.
dircache
.
clear
()
else
:
remove_paths
=
[]
else
:
dircache
=
self
.
dircache
paths
=
[
normpath
(
abspath
(
path
))
for
path
in
paths
]
for
cached_path
in
dircache
.
keys
():
...
...
@@ -1189,7 +1185,7 @@ class FTPFS(FS):
raise
ResourceInvalidError
(
path
)
if
not
force
:
for
checkpath
in
self
.
listdir
(
path
):
for
_
checkpath
in
self
.
listdir
(
path
):
raise
DirectoryNotEmptyError
(
path
)
try
:
if
force
:
...
...
fs/httpfs.py
View file @
4ae6f3a3
...
...
@@ -8,7 +8,6 @@ fs.httpfs
from
fs.base
import
FS
from
fs.path
import
normpath
from
fs.errors
import
ResourceNotFoundError
,
UnsupportedError
from
urlparse
import
urlparse
from
urllib2
import
urlopen
,
URLError
class
HTTPFS
(
FS
):
...
...
@@ -33,9 +32,9 @@ class HTTPFS(FS):
try
:
f
=
urlopen
(
url
)
except
URLError
,
e
:
raise
ResourceNotFoundError
(
path
)
raise
ResourceNotFoundError
(
path
,
details
=
e
)
except
OSError
,
e
:
raise
ResourceNotFoundError
(
path
)
raise
ResourceNotFoundError
(
path
,
details
=
e
)
return
f
...
...
fs/mountfs.py
View file @
4ae6f3a3
...
...
@@ -122,7 +122,7 @@ class MountFS(FS):
return
self
,
"/"
,
path
def
getsyspath
(
self
,
path
,
allow_none
=
False
):
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
self
or
fs
is
None
:
if
allow_none
:
return
None
...
...
@@ -131,7 +131,7 @@ class MountFS(FS):
return
fs
.
getsyspath
(
delegate_path
,
allow_none
=
allow_none
)
def
getpathurl
(
self
,
path
,
allow_none
=
False
):
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
self
or
fs
is
None
:
if
allow_none
:
return
None
...
...
@@ -141,7 +141,7 @@ class MountFS(FS):
@synchronize
def
desc
(
self
,
path
):
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
self
:
if
fs
.
isdir
(
path
):
return
"Mount dir"
...
...
@@ -151,7 +151,7 @@ class MountFS(FS):
@synchronize
def
isdir
(
self
,
path
):
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
return
False
if
fs
is
self
:
...
...
@@ -161,7 +161,7 @@ class MountFS(FS):
@synchronize
def
isfile
(
self
,
path
):
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
return
False
if
fs
is
self
:
...
...
@@ -171,7 +171,7 @@ class MountFS(FS):
@synchronize
def
exists
(
self
,
path
):
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
return
False
if
fs
is
self
:
...
...
@@ -180,7 +180,7 @@ class MountFS(FS):
@synchronize
def
listdir
(
self
,
path
=
"/"
,
wildcard
=
None
,
full
=
False
,
absolute
=
False
,
dirs_only
=
False
,
files_only
=
False
):
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
raise
ResourceNotFoundError
(
path
)
...
...
@@ -222,7 +222,7 @@ class MountFS(FS):
@synchronize
def
ilistdir
(
self
,
path
=
"/"
,
wildcard
=
None
,
full
=
False
,
absolute
=
False
,
dirs_only
=
False
,
files_only
=
False
):
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
raise
ResourceNotFoundError
(
path
)
...
...
@@ -257,7 +257,7 @@ class MountFS(FS):
if
self
.
isdir
(
pathjoin
(
path
,
p
)):
yield
mkpath
(
p
)
elif
files_only
:
if
self
.
isfile
(
pathjoin
(
path
,
nm
)):
if
self
.
isfile
(
pathjoin
(
path
,
p
)):
yield
mkpath
(
p
)
else
:
yield
mkpath
(
p
)
...
...
@@ -265,7 +265,7 @@ class MountFS(FS):
@synchronize
def
makedir
(
self
,
path
,
recursive
=
False
,
allow_recreate
=
False
):
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
self
or
fs
is
None
:
raise
UnsupportedError
(
"make directory"
,
msg
=
"Can only makedir for mounted paths"
)
if
not
delegate_path
:
...
...
@@ -282,7 +282,7 @@ class MountFS(FS):
callable
=
object
.
open_callable
return
callable
(
path
,
mode
,
**
kwargs
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
self
or
fs
is
None
:
raise
ResourceNotFoundError
(
path
)
...
...
@@ -294,24 +294,24 @@ class MountFS(FS):
object
=
self
.
mount_tree
.
get
(
path
,
None
)
if
type
(
object
)
is
MountFS
.
FileMount
:
return
super
(
MountFS
,
self
)
.
setcontents
(
path
,
data
,
chunk_size
=
chunk_size
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
self
or
fs
is
None
:
raise
ParentDirectoryMissingError
(
path
)
return
fs
.
setcontents
(
delegate_path
,
data
,
chunk_size
)
@synchronize
def
createfile
(
self
,
path
):
def
createfile
(
self
,
path
,
wipe
=
False
):
object
=
self
.
mount_tree
.
get
(
path
,
None
)
if
type
(
object
)
is
MountFS
.
FileMount
:
return
super
(
MountFS
,
self
)
.
setcontents
(
path
,
contents
,
chunk_size
=
chunk_siz
e
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
return
super
(
MountFS
,
self
)
.
createfile
(
path
,
wipe
=
wip
e
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
self
or
fs
is
None
:
raise
ParentDirectoryMissingError
(
path
)
return
fs
.
createfile
(
delegate_path
)
return
fs
.
createfile
(
delegate_path
,
wipe
=
wipe
)
@synchronize
def
remove
(
self
,
path
):
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
self
or
fs
is
None
:
raise
UnsupportedError
(
"remove file"
,
msg
=
"Can only remove paths within a mounted dir"
)
return
fs
.
remove
(
delegate_path
)
...
...
@@ -319,15 +319,15 @@ class MountFS(FS):
@synchronize
def
removedir
(
self
,
path
,
recursive
=
False
,
force
=
False
):
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
self
or
fs
is
None
:
raise
ResourceInvalidError
(
path
,
msg
=
"Can not removedir for an un-mounted path"
)
return
fs
.
removedir
(
delegate_path
,
recursive
,
force
)
@synchronize
def
rename
(
self
,
src
,
dst
):
fs1
,
mount_path1
,
delegate_path1
=
self
.
_delegate
(
src
)
fs2
,
mount_path2
,
delegate_path2
=
self
.
_delegate
(
dst
)
fs1
,
_
mount_path1
,
delegate_path1
=
self
.
_delegate
(
src
)
fs2
,
_
mount_path2
,
delegate_path2
=
self
.
_delegate
(
dst
)
if
fs1
is
not
fs2
:
raise
OperationFailedError
(
"rename resource"
,
path
=
src
)
...
...
@@ -335,10 +335,10 @@ class MountFS(FS):
if
fs1
is
not
self
:
return
fs1
.
rename
(
delegate_path1
,
delegate_path2
)
object
=
self
.
mount_tree
.
get
(
path_
src
,
None
)
object2
=
self
.
mount_tree
.
get
(
path_
dst
,
None
)
object
=
self
.
mount_tree
.
get
(
src
,
None
)
_object2
=
self
.
mount_tree
.
get
(
dst
,
None
)
if
object
1
is
None
:
if
object
is
None
:
raise
ResourceNotFoundError
(
src
)
# TODO!
...
...
@@ -346,8 +346,8 @@ class MountFS(FS):
@synchronize
def
move
(
self
,
src
,
dst
,
**
kwds
):
fs1
,
mount_path1
,
delegate_path1
=
self
.
_delegate
(
src
)
fs2
,
mount_path2
,
delegate_path2
=
self
.
_delegate
(
dst
)
fs1
,
_
mount_path1
,
delegate_path1
=
self
.
_delegate
(
src
)
fs2
,
_
mount_path2
,
delegate_path2
=
self
.
_delegate
(
dst
)
if
fs1
is
fs2
and
fs1
is
not
self
:
fs1
.
move
(
delegate_path1
,
delegate_path2
,
**
kwds
)
else
:
...
...
@@ -355,8 +355,8 @@ class MountFS(FS):
@synchronize
def
movedir
(
self
,
src
,
dst
,
**
kwds
):
fs1
,
mount_path1
,
delegate_path1
=
self
.
_delegate
(
src
)
fs2
,
mount_path2
,
delegate_path2
=
self
.
_delegate
(
dst
)
fs1
,
_
mount_path1
,
delegate_path1
=
self
.
_delegate
(
src
)
fs2
,
_
mount_path2
,
delegate_path2
=
self
.
_delegate
(
dst
)
if
fs1
is
fs2
and
fs1
is
not
self
:
fs1
.
movedir
(
delegate_path1
,
delegate_path2
,
**
kwds
)
else
:
...
...
@@ -364,8 +364,8 @@ class MountFS(FS):
@synchronize
def
copy
(
self
,
src
,
dst
,
**
kwds
):
fs1
,
mount_path1
,
delegate_path1
=
self
.
_delegate
(
src
)
fs2
,
mount_path2
,
delegate_path2
=
self
.
_delegate
(
dst
)
fs1
,
_
mount_path1
,
delegate_path1
=
self
.
_delegate
(
src
)
fs2
,
_
mount_path2
,
delegate_path2
=
self
.
_delegate
(
dst
)
if
fs1
is
fs2
and
fs1
is
not
self
:
fs1
.
copy
(
delegate_path1
,
delegate_path2
,
**
kwds
)
else
:
...
...
@@ -373,8 +373,8 @@ class MountFS(FS):
@synchronize
def
copydir
(
self
,
src
,
dst
,
**
kwds
):
fs1
,
mount_path1
,
delegate_path1
=
self
.
_delegate
(
src
)
fs2
,
mount_path2
,
delegate_path2
=
self
.
_delegate
(
dst
)
fs1
,
_
mount_path1
,
delegate_path1
=
self
.
_delegate
(
src
)
fs2
,
_
mount_path2
,
delegate_path2
=
self
.
_delegate
(
dst
)
if
fs1
is
fs2
and
fs1
is
not
self
:
fs1
.
copydir
(
delegate_path1
,
delegate_path2
,
**
kwds
)
else
:
...
...
@@ -414,7 +414,7 @@ class MountFS(FS):
@synchronize
def
settimes
(
self
,
path
,
accessed_time
=
None
,
modified_time
=
None
):
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
raise
ResourceNotFoundError
(
path
)
...
...
@@ -427,7 +427,7 @@ class MountFS(FS):
def
getinfo
(
self
,
path
):
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
raise
ResourceNotFoundError
(
path
)
...
...
@@ -441,7 +441,7 @@ class MountFS(FS):
@synchronize
def
getsize
(
self
,
path
):
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
raise
ResourceNotFoundError
(
path
)
...
...
@@ -462,7 +462,7 @@ class MountFS(FS):
@synchronize
def
getxattr
(
self
,
path
,
name
,
default
=
None
):
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
raise
ResourceNotFoundError
(
path
)
if
fs
is
self
:
...
...
@@ -472,7 +472,7 @@ class MountFS(FS):
@synchronize
def
setxattr
(
self
,
path
,
name
,
value
):
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
raise
ResourceNotFoundError
(
path
)
if
fs
is
self
:
...
...
@@ -482,17 +482,17 @@ class MountFS(FS):
@synchronize
def
delxattr
(
self
,
path
,
name
):
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
raise
ResourceNotFoundError
(
path
)
if
fs
is
self
:
return
True
return
fs
.
delxattr
(
delegate_path
,
name
)
return
fs
.
delxattr
(
delegate_path
,
name
)
@synchronize
def
listxattrs
(
self
,
path
):
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
fs
,
_
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
raise
ResourceNotFoundError
(
path
)
if
fs
is
self
:
...
...
fs/path.py
View file @
4ae6f3a3
...
...
@@ -152,10 +152,10 @@ def pathjoin(*paths):
relpaths
=
[]
for
p
in
paths
:
if
p
:
if
p
[
0
]
in
'
\\
/'
:
del
relpaths
[:]
absolute
=
True
relpaths
.
append
(
p
)
if
p
[
0
]
in
'
\\
/'
:
del
relpaths
[:]
absolute
=
True
relpaths
.
append
(
p
)
path
=
normpath
(
u"/"
.
join
(
relpaths
))
if
absolute
:
...
...
fs/remote.py
View file @
4ae6f3a3
...
...
@@ -22,15 +22,12 @@ FS subclasses interfacing with a remote filesystem. These include:
from
__future__
import
with_statement
import
sys
import
os
import
time
import
copy
import
stat
as
statinfo
from
errno
import
EINVAL
import
fs.utils
from
fs.base
import
FS
,
threading
from
fs.base
import
threading
from
fs.wrapfs
import
WrapFS
,
wrap_fs_methods
from
fs.wrapfs.lazyfs
import
LazyFS
from
fs.path
import
*
...
...
@@ -621,10 +618,10 @@ class CacheFSMixin(WrapFS):
return
info
def
listdir
(
self
,
path
=
""
,
*
args
,
**
kwds
):
return
list
(
nm
for
(
nm
,
info
)
in
self
.
listdirinfo
(
path
,
*
args
,
**
kwds
))
return
list
(
nm
for
(
nm
,
_
info
)
in
self
.
listdirinfo
(
path
,
*
args
,
**
kwds
))
def
ilistdir
(
self
,
path
=
""
,
*
args
,
**
kwds
):
for
(
nm
,
info
)
in
self
.
ilistdirinfo
(
path
,
*
args
,
**
kwds
):
for
(
nm
,
_
info
)
in
self
.
ilistdirinfo
(
path
,
*
args
,
**
kwds
):
yield
nm
def
listdirinfo
(
self
,
path
=
""
,
*
args
,
**
kwds
):
...
...
fs/s3fs.py
View file @
4ae6f3a3
...
...
@@ -9,10 +9,7 @@ interface for objects stored in Amazon Simple Storage Service (S3).
"""
import
os
import
time
import
datetime
import
hashlib
import
tempfile
from
fnmatch
import
fnmatch
import
stat
as
statinfo
...
...
@@ -322,7 +319,7 @@ class S3FS(FS):
return
False
k
=
self
.
_s3bukt
.
get_key
(
s3path
)
if
k
is
not
None
:
return
True
return
True
return
False
def
listdir
(
self
,
path
=
"./"
,
wildcard
=
None
,
full
=
False
,
absolute
=
False
,
dirs_only
=
False
,
files_only
=
False
):
...
...
fs/sftpfs.py
View file @
4ae6f3a3
...
...
@@ -481,7 +481,7 @@ class SFTPFS(FS):
self
.
client
.
rename
(
nsrc
,
ndst
)
except
IOError
,
e
:
if
getattr
(
e
,
"errno"
,
None
)
==
2
:
raise
ResourceNotFoundError
(
path
)
raise
ResourceNotFoundError
(
src
)
if
not
self
.
isdir
(
dirname
(
dst
)):
raise
ParentDirectoryMissingError
(
dst
)
raise
...
...
@@ -496,7 +496,7 @@ class SFTPFS(FS):
self
.
client
.
rename
(
nsrc
,
ndst
)
except
IOError
,
e
:
if
getattr
(
e
,
"errno"
,
None
)
==
2
:
raise
ResourceNotFoundError
(
path
)
raise
ResourceNotFoundError
(
src
)
if
self
.
exists
(
dst
):
raise
DestinationExistsError
(
dst
)
if
not
self
.
isdir
(
dirname
(
dst
)):
...
...
fs/utils.py
View file @
4ae6f3a3
...
...
@@ -14,7 +14,6 @@ __all__ = ['copyfile',
'find_duplicates'
,
'print_fs'
]
import
shutil
import
os
import
sys
import
stat
...
...
@@ -453,9 +452,9 @@ def print_fs(fs, path='/', max_levels=5, file_out=None, terminal_colors=None, hi
file_out
.
write
(
line
.
encode
(
file_encoding
,
'replace'
)
+
'
\n
'
)
def
wrap_prefix
(
prefix
):
if
not
terminal_colors
:
return
prefix
return
'
\x1b
[34m
%
s
\x1b
[0m'
%
prefix
if
not
terminal_colors
:
return
prefix
return
'
\x1b
[34m
%
s
\x1b
[0m'
%
prefix
def
wrap_dirname
(
dirname
):
if
not
terminal_colors
:
...
...
fs/watch.py
View file @
4ae6f3a3
...
...
@@ -318,7 +318,7 @@ class WatchableFS(WatchableFSMixin,WrapFS):
if
not
existed
:
self
.
notify_watchers
(
CREATED
,
path
)
self
.
notify_watchers
(
ACCESSED
,
path
)
return
ret
q
return
ret
def
makedir
(
self
,
path
,
recursive
=
False
,
allow_recreate
=
False
):
existed
=
self
.
wrapped_fs
.
isdir
(
path
)
...
...
@@ -441,7 +441,7 @@ class WatchableFS(WatchableFSMixin,WrapFS):
self
.
notify_watchers
(
MODIFIED
,
path
,
False
)
def
delxattr
(
self
,
path
,
name
):
super
(
WatchableFS
,
self
)
.
delxattr
(
path
,
name
,
value
)
super
(
WatchableFS
,
self
)
.
delxattr
(
path
,
name
)
self
.
notify_watchers
(
MODIFIED
,
path
,
False
)
...
...
fs/zipfs.py
View file @
4ae6f3a3
...
...
@@ -151,7 +151,7 @@ class ZipFS(FS):
if
path
:
self
.
_path_fs
.
makedir
(
path
,
recursive
=
True
,
allow_recreate
=
True
)
else
:
dirpath
,
filename
=
pathsplit
(
path
)
dirpath
,
_
filename
=
pathsplit
(
path
)
if
dirpath
:
self
.
_path_fs
.
makedir
(
dirpath
,
recursive
=
True
,
allow_recreate
=
True
)
f
=
self
.
_path_fs
.
open
(
path
,
'w'
)
...
...
@@ -191,7 +191,7 @@ class ZipFS(FS):
raise
OperationFailedError
(
"open file"
,
path
=
path
,
msg
=
"2 Zip file must be opened for writing ('w') or appending ('a')"
)
dirname
,
filename
=
pathsplit
(
path
)
dirname
,
_
filename
=
pathsplit
(
path
)
if
dirname
:
self
.
temp_fs
.
makedir
(
dirname
,
recursive
=
True
,
allow_recreate
=
True
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment