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
f24a6884
Commit
f24a6884
authored
Aug 11, 2008
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some changes to the MountFS
parent
274827b9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
0 deletions
+81
-0
fs/fs.py
+2
-0
fs/mountfs.py
+79
-0
No files found.
fs/fs.py
View file @
f24a6884
...
...
@@ -20,6 +20,8 @@ error_msgs = {
"RENAME_FAILED"
:
"Unable to rename file:
%(path)
s"
,
"OPEN_FAILED"
:
"Unable to open file:
%(path)
s"
,
"DIR_EXISTS"
:
"Directory exists (try allow_recreate=True):
%(path)
s"
,
"REMOVE_FAILED"
:
"Unable to remove file:
%(path)
s"
,
"REMOVEDIR_FAILED"
:
"Unable to remove dir:
%(path)
s"
,
# NoSysPathError
"NO_SYS_PATH"
:
"No mapping to OS filesytem:
%(path)
s,"
,
...
...
fs/mountfs.py
View file @
f24a6884
...
...
@@ -110,6 +110,7 @@ class MountFS(FS):
def
open
(
self
,
path
,
mode
=
"r"
,
**
kwargs
):
path
=
normpath
(
path
)
object
=
self
.
mount_tree
.
get
(
path
,
None
)
if
type
(
object
)
is
MountFS
.
FileMount
:
callable
=
object
.
open_callable
...
...
@@ -122,6 +123,63 @@ class MountFS(FS):
return
fs
.
open
(
delegate_path
,
mode
,
**
kwargs
)
def
exists
(
self
,
path
):
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
return
False
if
fs
is
self
:
return
path
in
self
.
mount_tree
return
fs
.
exists
(
delegate_path
)
def
removedir
(
self
,
path
,
recursive
=
False
):
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
not
self
:
return
fs
.
removedir
(
delegate_path
,
path
)
object
=
self
.
mount_tree
.
get
(
path
,
None
)
if
object
is
None
or
not
isinstance
(
object
,
dict
):
raise
ResourceNotFound
(
"NO_DIR"
,
path
)
if
not
recursive
and
len
(
object
):
raise
OperationFailedError
(
"REMOVEDIR_FAILED"
,
path
)
del
self
.
mount_tree
[
delegate_path
]
def
rename
(
self
,
src
,
dst
):
fs1
,
mount_path1
,
delegate_path1
=
self
.
_delegate
(
path
)
fs2
,
mount_path2
,
delegate_path2
=
self
.
_delegate
(
path
)
if
fs1
is
not
fs2
:
raise
OperationFailedError
(
"RENAME_FAILED"
,
src
)
if
fs1
is
not
self
:
return
fs1
.
rename
(
delegate_path1
,
delegate_path2
)
path_src
=
normpath
(
src
)
path_dst
=
normpath
(
dst
)
object
=
self
.
mount_tree
.
get
(
path_src
,
None
)
object2
=
self
.
mount_tree
.
get
(
path_dst
,
None
)
if
object1
is
None
:
raise
NoResourceError
(
"NO_RESOURCE"
,
src
)
# TODO!
raise
UnsupportedError
(
"UNSUPPORTED"
,
src
)
def
mountdir
(
self
,
path
,
fs
):
path
=
normpath
(
path
)
...
...
@@ -145,6 +203,27 @@ class MountFS(FS):
return
self
.
mount_tree
[
path
]
.
info_callable
(
path
)
return
{}
return
fs
.
getinfo
(
delegate_path
)
def
getsize
(
self
,
path
):
path
=
normpath
(
path
)
fs
,
mount_path
,
delegate_path
=
self
.
_delegate
(
path
)
if
fs
is
None
:
raise
ResourceNotFoundError
(
"NO_FILE"
,
path
)
if
fs
is
self
:
object
=
self
.
mount_tree
.
get
(
path
,
None
)
if
object
is
None
or
isinstance
(
object
,
dict
):
raise
ResourceNotFoundError
(
"NO_FILE"
,
path
)
size
=
self
.
mount_tree
[
path
]
.
info_callable
(
path
)
.
get
(
"size"
,
None
)
return
size
return
fs
.
getinfo
(
delegate_path
)
.
getsize
()
#
#class MountFS(FS):
#
...
...
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