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
1cde4462
Commit
1cde4462
authored
Jul 28, 2008
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work in progress
parent
338423c7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
9 deletions
+87
-9
fs/fs.py
+4
-4
fs/multifs.py
+83
-5
No files found.
fs/fs.py
View file @
1cde4462
...
@@ -197,7 +197,7 @@ class FS(object):
...
@@ -197,7 +197,7 @@ class FS(object):
raise
FSError
(
"NO_SYS_PATH"
,
path
)
raise
FSError
(
"NO_SYS_PATH"
,
path
)
def
open
(
self
,
path
name
,
mode
=
"r"
,
buffering
=-
1
,
**
kwargs
):
def
open
(
self
,
path
,
mode
=
"r"
,
buffering
=-
1
,
**
kwargs
):
pass
pass
...
@@ -407,9 +407,9 @@ class OSFS(FS):
...
@@ -407,9 +407,9 @@ class OSFS(FS):
sys_path
=
self
.
getsyspath
(
path
)
sys_path
=
self
.
getsyspath
(
path
)
if
recursive
:
if
recursive
:
makedirs
(
sys_path
,
mode
)
os
.
makedirs
(
sys_path
,
mode
)
else
:
else
:
makedir
(
sys_path
,
mode
)
os
.
makedir
(
sys_path
,
mode
)
def
remove
(
self
,
path
):
def
remove
(
self
,
path
):
...
@@ -421,7 +421,7 @@ class OSFS(FS):
...
@@ -421,7 +421,7 @@ class OSFS(FS):
raise
FSError
(
"FILE_DELETE_FAILED"
,
path
,
details
=
e
)
raise
FSError
(
"FILE_DELETE_FAILED"
,
path
,
details
=
e
)
def
remove
_
dir
(
self
,
path
,
recursive
=
False
):
def
removedir
(
self
,
path
,
recursive
=
False
):
sys_path
=
self
.
getsyspath
(
path
)
sys_path
=
self
.
getsyspath
(
path
)
...
...
fs/multifs.py
View file @
1cde4462
#!/usr/
b
in/env python
#!/usr/in/env python
from
fs
import
FS
from
fs
import
FS
,
FSError
class
MultiFS
(
FS
):
class
MultiFS
(
FS
):
...
@@ -10,10 +10,17 @@ class MultiFS(FS):
...
@@ -10,10 +10,17 @@ class MultiFS(FS):
self
.
fs_sequence
=
[]
self
.
fs_sequence
=
[]
self
.
fs_lookup
=
{}
self
.
fs_lookup
=
{}
def
__str__
(
self
):
return
"<MultiFS:
%
s>"
%
", "
.
join
(
str
(
fs
)
for
fs
in
self
.
fs_sequence
)
def
add_fs
(
self
,
name
,
fs
):
def
add_fs
(
self
,
name
,
fs
):
self
.
fs_sequence
.
append
(
name
,
fs
)
if
name
in
self
.
fs_lookup
:
raise
ValueError
(
"Name already exists."
)
self
.
fs_sequence
.
append
(
fs
)
self
.
fs_lookup
[
name
]
=
fs
self
.
fs_lookup
[
name
]
=
fs
...
@@ -28,8 +35,6 @@ class MultiFS(FS):
...
@@ -28,8 +35,6 @@ class MultiFS(FS):
return
self
.
fs_lookup
[
name
]
return
self
.
fs_lookup
[
name
]
def
__iter__
(
self
):
def
__iter__
(
self
):
return
iter
(
self
.
fs_sequence
)
return
iter
(
self
.
fs_sequence
)
...
@@ -41,7 +46,80 @@ class MultiFS(FS):
...
@@ -41,7 +46,80 @@ class MultiFS(FS):
return
fs
return
fs
return
None
return
None
def
getsyspath
(
self
,
path
):
fs
=
self
.
_delegate_search
(
path
)
if
fs
is
not
None
:
return
fs
.
getsyspath
(
path
)
raise
FSError
(
"NO_FILE"
,
path
)
def
open
(
self
,
path
,
mode
=
"r"
,
buffering
=-
1
,
**
kwargs
):
for
fs
in
self
:
if
fs
.
exists
(
path
):
fs_file
=
fs
.
open
(
path
,
mode
,
buffering
,
**
kwargs
)
return
fs_file
raise
FSError
(
"NO_FILE"
,
path
)
def
exists
(
self
,
path
):
def
exists
(
self
,
path
):
return
self
.
_delegate_search
(
path
)
is
not
None
return
self
.
_delegate_search
(
path
)
is
not
None
def
isdir
(
self
,
path
):
fs
=
self
.
_delegate_search
(
path
)
if
fs
is
not
None
:
return
fs
.
isdir
()
return
False
def
isfile
(
self
,
path
):
fs
=
self
.
_delegate_search
(
path
)
if
fs
is
not
None
:
return
fs
.
isfile
()
return
False
def
ishidden
(
self
,
path
):
fs
=
self
.
_delegate_search
(
path
)
if
fs
is
not
None
:
return
fs
.
isfile
()
return
False
def
listdir
(
self
,
path
=
"./"
,
*
args
,
**
kwargs
):
paths
=
[]
for
fs
in
self
:
try
:
paths
+=
fs
.
listdir
(
path
,
*
args
,
**
kwargs
)
except
FSError
,
e
:
pass
return
list
(
set
(
paths
))
def
remove
(
self
,
path
):
for
fs
in
self
:
if
fs
.
exist
(
path
):
fs
.
remove
(
path
)
return
raise
FSError
(
"NO_FILE"
,
path
)
def
removedir
(
self
,
path
,
recursive
=
False
):
for
fs
in
self
:
if
fs
.
isdir
(
path
):
fs
.
removedir
(
path
,
recursive
)
return
raise
FSError
(
"NO_DIR"
,
path
)
def
getinfo
(
self
,
path
):
for
fs
in
self
:
if
fs
.
exist
(
path
):
return
fs
.
getinfo
(
path
)
raise
FSError
(
"NO_FILE"
,
path
)
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