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
06ddab8a
Commit
06ddab8a
authored
Jul 22, 2008
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work in progress for memoryfs
parent
14f06e4f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
2 deletions
+46
-2
fs/memoryfs.py
+46
-2
No files found.
fs/memoryfs.py
View file @
06ddab8a
...
@@ -2,6 +2,29 @@
...
@@ -2,6 +2,29 @@
from
fs
import
FS
,
pathsplit
,
_iteratepath
,
FSError
,
print_fs
from
fs
import
FS
,
pathsplit
,
_iteratepath
,
FSError
,
print_fs
try
:
from
cStringIO
import
StringIO
except
ImportError
:
from
StringIO
import
StringIO
class
MemoryFile
(
StringIO
):
def
__init__
(
self
,
path
,
memory_fs
,
*
args
,
**
kwargs
):
self
.
path
=
path
self
.
memory_fs
=
memory_fs
StringIO
.
__init__
(
*
args
,
**
kwargs
)
def
close
():
value
=
self
.
get_vale
()
self
.
memory_fs
.
_on_close_memory_file
(
path
,
value
)
StringIO
.
close
(
self
)
class
MemoryFS
(
FS
):
class
MemoryFS
(
FS
):
class
DirEntry
(
object
):
class
DirEntry
(
object
):
...
@@ -32,6 +55,12 @@ class MemoryFS(FS):
...
@@ -32,6 +55,12 @@ class MemoryFS(FS):
def
__str__
(
self
):
def
__str__
(
self
):
return
"
%
s:
%
s"
%
(
self
.
name
,
self
.
desc_contents
())
return
"
%
s:
%
s"
%
(
self
.
name
,
self
.
desc_contents
())
class
FileEntry
(
object
):
def
__init__
(
self
):
self
.
memory_file
=
None
self
.
value
=
""
def
_make_dir_entry
(
self
,
*
args
,
**
kwargs
):
def
_make_dir_entry
(
self
,
*
args
,
**
kwargs
):
return
self
.
dir_entry_factory
(
*
args
,
**
kwargs
)
return
self
.
dir_entry_factory
(
*
args
,
**
kwargs
)
...
@@ -58,7 +87,7 @@ class MemoryFS(FS):
...
@@ -58,7 +87,7 @@ class MemoryFS(FS):
def
getsyspath
(
self
,
pathname
):
def
getsyspath
(
self
,
pathname
):
raise
FSError
(
"NO_SYS_PATH"
,
"This file-system has no
t syspath!
"
,
pathname
)
raise
FSError
(
"NO_SYS_PATH"
,
"This file-system has no
syspath
"
,
pathname
)
def
isdir
(
self
,
path
):
def
isdir
(
self
,
path
):
...
@@ -131,9 +160,24 @@ class MemoryFS(FS):
...
@@ -131,9 +160,24 @@ class MemoryFS(FS):
if
dir_item
is
None
:
if
dir_item
is
None
:
parent_dir
.
contents
[
dirname
]
=
self
.
_make_dir_entry
(
"dir"
,
dirname
)
parent_dir
.
contents
[
dirname
]
=
self
.
_make_dir_entry
(
"dir"
,
dirname
)
return
self
def
open
(
self
,
path
,
mode
,
**
kwargs
):
dir_entry
=
self
.
_get_dir_entry
(
path
)
if
dir_entry
is
None
:
dirpath
,
dirname
=
pathsplit
(
path
)
parent_dir_entry
=
self
.
_get_dir_entry
(
dirpath
)
if
parent_dir_entry
is
None
:
raise
FSError
(
"DOES_NOT_EXIST"
,
"File does not exist"
,
path
)
def
_on_close_memory_file
(
self
,
path
,
value
):
dir_entry
=
self
.
_get_dir_entry
(
path
)
return
self
def
listdir
(
self
,
path
=
"/"
,
wildcard
=
None
,
full
=
False
,
absolute
=
False
,
hidden
=
False
,
dirs_only
=
False
,
files_only
=
False
):
def
listdir
(
self
,
path
=
"/"
,
wildcard
=
None
,
full
=
False
,
absolute
=
False
,
hidden
=
False
,
dirs_only
=
False
,
files_only
=
False
):
...
...
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