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
0eb346d0
Commit
0eb346d0
authored
Mar 17, 2013
by
willmcgugan@gmail.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some minor fixes and doc changes
parent
3ab791f1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
16 deletions
+32
-16
fs/mountfs.py
+32
-16
No files found.
fs/mountfs.py
View file @
0eb346d0
...
...
@@ -166,10 +166,13 @@ class MountFS(FS):
def
isdir
(
self
,
path
):
fs
,
_mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
path
=
normpath
(
path
)
if
path
in
(
"/"
,
""
):
return
True
return
False
if
fs
is
self
:
obj
ect
=
self
.
mount_tree
.
get
(
path
,
None
)
return
not
isinstance
(
obj
ect
,
MountFS
.
FileMount
)
obj
=
self
.
mount_tree
.
get
(
path
,
None
)
return
not
isinstance
(
obj
,
MountFS
.
FileMount
)
return
fs
.
isdir
(
delegate_path
)
@synchronize
...
...
@@ -178,12 +181,14 @@ class MountFS(FS):
if
fs
is
None
:
return
False
if
fs
is
self
:
obj
ect
=
self
.
mount_tree
.
get
(
path
,
None
)
return
isinstance
(
obj
ect
,
MountFS
.
FileMount
)
obj
=
self
.
mount_tree
.
get
(
path
,
None
)
return
isinstance
(
obj
,
MountFS
.
FileMount
)
return
fs
.
isfile
(
delegate_path
)
@synchronize
def
exists
(
self
,
path
):
if
path
in
(
"/"
,
""
):
return
True
fs
,
_mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
return
False
...
...
@@ -196,9 +201,11 @@ class MountFS(FS):
fs
,
_mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
raise
ResourceNotFoundError
(
path
)
if
path
in
(
"/"
,
""
):
return
[]
raise
ResourceNotFoundError
(
"path"
)
if
fs
is
self
:
el
if
fs
is
self
:
paths
=
self
.
mount_tree
.
names
(
path
)
return
self
.
_listdir_helper
(
path
,
paths
,
...
...
@@ -289,9 +296,9 @@ class MountFS(FS):
@synchronize
def
open
(
self
,
path
,
mode
=
"r"
,
**
kwargs
):
obj
ect
=
self
.
mount_tree
.
get
(
path
,
None
)
if
type
(
obj
ect
)
is
MountFS
.
FileMount
:
callable
=
obj
ect
.
open_callable
obj
=
self
.
mount_tree
.
get
(
path
,
None
)
if
type
(
obj
)
is
MountFS
.
FileMount
:
callable
=
obj
.
open_callable
return
callable
(
path
,
mode
,
**
kwargs
)
fs
,
_mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
...
...
@@ -303,8 +310,8 @@ class MountFS(FS):
@synchronize
def
setcontents
(
self
,
path
,
data
,
chunk_size
=
64
*
1024
):
obj
ect
=
self
.
mount_tree
.
get
(
path
,
None
)
if
type
(
obj
ect
)
is
MountFS
.
FileMount
:
obj
=
self
.
mount_tree
.
get
(
path
,
None
)
if
type
(
obj
)
is
MountFS
.
FileMount
:
return
super
(
MountFS
,
self
)
.
setcontents
(
path
,
data
,
chunk_size
=
chunk_size
)
fs
,
_mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
self
or
fs
is
None
:
...
...
@@ -313,8 +320,8 @@ class MountFS(FS):
@synchronize
def
createfile
(
self
,
path
,
wipe
=
False
):
obj
ect
=
self
.
mount_tree
.
get
(
path
,
None
)
if
type
(
obj
ect
)
is
MountFS
.
FileMount
:
obj
=
self
.
mount_tree
.
get
(
path
,
None
)
if
type
(
obj
)
is
MountFS
.
FileMount
:
return
super
(
MountFS
,
self
)
.
createfile
(
path
,
wipe
=
wipe
)
fs
,
_mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
self
or
fs
is
None
:
...
...
@@ -410,8 +417,10 @@ class MountFS(FS):
"""Mounts a single file path.
:param path: A path within the MountFS
:param open_callable: A callable that returns a file-like object
:param info_callable: A callable that returns a dictionary with information regarding the file-like object
:param open_callable: A callable that returns a file-like object,
`open_callable` should have the same signature as :py:meth:`~fs.base.FS.open`
:param info_callable: A callable that returns a dictionary with information regarding the file-like object,
`info_callable` should have the same signagture as :py:meth:`~fs.base.FS.getinfo`
"""
self
.
mount_tree
[
path
]
=
MountFS
.
FileMount
(
path
,
open_callable
,
info_callable
)
...
...
@@ -421,9 +430,16 @@ class MountFS(FS):
"""Unmounts a path.
:param path: Path to unmount
:return: True if a dir was unmounted, False if the path was already unmounted
:rtype: bool
"""
del
self
.
mount_tree
[
path
]
try
:
del
self
.
mount_tree
[
path
]
except
KeyError
:
return
False
else
:
return
True
@synchronize
def
settimes
(
self
,
path
,
accessed_time
=
None
,
modified_time
=
None
):
...
...
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