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
338423c7
Commit
338423c7
authored
Jul 28, 2008
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
work in progress
parent
7c35df5a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
10 deletions
+53
-10
fs/fs.py
+50
-8
fs/multifs.py
+3
-2
No files found.
fs/fs.py
View file @
338423c7
...
@@ -10,6 +10,7 @@ import datetime
...
@@ -10,6 +10,7 @@ import datetime
error_msgs
=
{
error_msgs
=
{
"UNKNOWN_ERROR"
:
"No information on error:
%(path)
s"
,
"UNKNOWN_ERROR"
:
"No information on error:
%(path)
s"
,
"UNSUPPORTED"
:
"This filesystem does not support this action."
,
"INVALID_PATH"
:
"Path is invalid:
%(path)
s"
,
"INVALID_PATH"
:
"Path is invalid:
%(path)
s"
,
"NO_DIR"
:
"Directory does not exist:
%(path)
s"
,
"NO_DIR"
:
"Directory does not exist:
%(path)
s"
,
"NO_FILE"
:
"No such file:
%(path)
s"
,
"NO_FILE"
:
"No such file:
%(path)
s"
,
...
@@ -192,22 +193,26 @@ class FS(object):
...
@@ -192,22 +193,26 @@ class FS(object):
return
pathjoin
(
'/'
,
pathname
)
return
pathjoin
(
'/'
,
pathname
)
return
pathname
return
pathname
def
getsyspath
(
self
,
path
):
raise
FSError
(
"NO_SYS_PATH"
,
path
)
def
open
(
self
,
pathname
,
mode
=
"r"
,
buffering
=-
1
,
**
kwargs
):
def
open
(
self
,
pathname
,
mode
=
"r"
,
buffering
=-
1
,
**
kwargs
):
pass
pass
def
open_dir
(
self
,
dirname
):
def
open_dir
(
self
,
path
):
if
not
self
.
exists
(
dirname
):
if
not
self
.
exists
(
path
):
raise
FSError
(
"NO_DIR"
,
dirname
)
raise
FSError
(
"NO_DIR"
,
path
)
sub_fs
=
SubFS
(
self
,
dirname
)
sub_fs
=
SubFS
(
self
,
path
)
return
sub_fs
return
sub_fs
def
remove
(
self
,
filepath
):
pass
def
remove
(
self
,
path
):
raise
FSError
(
"UNSUPPORTED"
,
path
)
def
_listdir_helper
(
self
,
path
,
paths
,
wildcard
,
full
,
absolute
,
hidden
,
dirs_only
,
files_only
):
def
_listdir_helper
(
self
,
path
,
paths
,
wildcard
,
full
,
absolute
,
hidden
,
dirs_only
,
files_only
):
...
@@ -243,9 +248,9 @@ class FS(object):
...
@@ -243,9 +248,9 @@ class FS(object):
while
dirs
:
while
dirs
:
path
=
dirs
.
pop
()
current_
path
=
dirs
.
pop
()
for
path
in
self
.
listdir
(
path
,
full
=
True
):
for
path
in
self
.
listdir
(
current_
path
,
full
=
True
):
if
self
.
isdir
(
path
):
if
self
.
isdir
(
path
):
if
dir_wildcard
is
not
None
:
if
dir_wildcard
is
not
None
:
if
fnmatch
.
fnmatch
(
path
,
dir_wilcard
):
if
fnmatch
.
fnmatch
(
path
,
dir_wilcard
):
...
@@ -259,6 +264,34 @@ class FS(object):
...
@@ -259,6 +264,34 @@ class FS(object):
else
:
else
:
yield
path
yield
path
def
walk
(
self
,
path
=
"/"
,
wildcard
=
None
,
dir_wildcard
=
None
):
dirs
=
[
path
]
while
dirs
:
current_path
=
dirs
.
pop
()
paths
=
[]
for
path
in
self
.
listdir
(
current_path
,
full
=
True
):
if
self
.
isdir
(
path
):
if
dir_wildcard
is
not
None
:
if
fnmatch
.
fnmatch
(
path
,
dir_wilcard
):
dirs
.
append
(
path
)
else
:
dirs
.
append
(
path
)
else
:
if
wildcard
is
not
None
:
if
fnmatch
.
fnmatch
(
path
,
wildcard
):
paths
.
append
(
path
)
else
:
paths
.
append
(
path
)
yield
(
current_path
,
paths
)
def
getsize
(
self
,
path
):
def
getsize
(
self
,
path
):
...
@@ -287,6 +320,15 @@ class SubFS(FS):
...
@@ -287,6 +320,15 @@ class SubFS(FS):
def
open
(
self
,
pathname
,
mode
=
"r"
,
buffering
=-
1
,
**
kwargs
):
def
open
(
self
,
pathname
,
mode
=
"r"
,
buffering
=-
1
,
**
kwargs
):
return
self
.
parent
.
open
(
self
.
_delegate
(
pathname
),
mode
,
buffering
)
return
self
.
parent
.
open
(
self
.
_delegate
(
pathname
),
mode
,
buffering
)
def
open_dir
(
self
,
path
):
if
not
self
.
exists
(
dirname
):
raise
FSError
(
"NO_DIR"
,
dirname
)
path
=
self
.
_delegate
(
path
)
sub_fs
=
self
.
parent
.
open_dir
(
path
)
return
sub_fs
def
isdir
(
self
,
pathname
):
def
isdir
(
self
,
pathname
):
...
...
fs/multifs.py
View file @
338423c7
...
@@ -23,12 +23,13 @@ class MultiFS(FS):
...
@@ -23,12 +23,13 @@ class MultiFS(FS):
self
.
fs_sequence
.
remove
(
fs
)
self
.
fs_sequence
.
remove
(
fs
)
del
self
.
fs_lookup
[
name
]
del
self
.
fs_lookup
[
name
]
def
__getitem__
(
self
,
name
):
def
__getitem__
(
self
,
name
):
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
)
...
...
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