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
274827b9
Commit
274827b9
authored
Aug 02, 2008
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor and ehancements to mountfs
parent
fe9f7194
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
6 deletions
+31
-6
fs/browsewin.py
+4
-3
fs/memoryfs.py
+3
-0
fs/mountfs.py
+0
-0
fs/objecttree.py
+24
-3
No files found.
fs/browsewin.py
View file @
274827b9
...
...
@@ -15,7 +15,7 @@ class BrowseFrame(wx.Frame):
self
.
SetTitle
(
"FS Browser - "
+
str
(
fs
))
self
.
tree
=
wx
.
gizmos
.
TreeListCtrl
(
self
,
-
1
,
style
=
wx
.
TR_DEFAULT_STYLE
|
wx
.
TR_HIDE_ROOT
)
self
.
tree
.
AddColumn
(
"FS"
,
300
)
self
.
tree
.
AddColumn
(
"FS"
,
300
)
self
.
tree
.
AddColumn
(
"Description"
,
250
)
self
.
tree
.
AddColumn
(
"Size"
,
150
)
self
.
tree
.
AddColumn
(
"Created"
,
250
)
...
...
@@ -97,7 +97,7 @@ class BrowseFrame(wx.Frame):
self
.
tree
.
SetItemText
(
new_item
,
ct
.
ctime
(),
3
)
else
:
self
.
tree
.
SetItemText
(
new_item
,
'unknown'
,
3
)
self
.
tree
.
SetItemText
(
new_item
,
self
.
fs
.
desc
(
new_path
),
1
)
item_data
[
'expanded'
]
=
True
...
...
@@ -119,5 +119,6 @@ def browse(fs):
if
__name__
==
"__main__"
:
home_fs
=
fs
.
OSFS
(
"~/"
)
from
osfs
import
OSFS
home_fs
=
OSFS
(
"~/"
)
browse
(
home_fs
)
fs/memoryfs.py
View file @
274827b9
...
...
@@ -321,6 +321,9 @@ class MemoryFS(FS):
def
getinfo
(
self
,
path
):
dir_entry
=
self
.
_get_dir_entry
(
path
)
if
dir_entry
is
None
:
raise
ResourceNotFoundError
(
"NO_RESOURCE"
,
path
)
info
=
{}
info
[
'created_time'
]
=
dir_entry
.
created_time
...
...
fs/mountfs.py
View file @
274827b9
This diff is collapsed.
Click to expand it.
fs/objecttree.py
View file @
274827b9
...
...
@@ -12,23 +12,26 @@ class ObjectTree(object):
def
__init__
(
self
):
self
.
root
=
_ObjectDict
()
def
_splitpath
(
self
,
path
):
return
[
p
for
p
in
path
.
split
(
'/'
)
if
p
]
def
_locate
(
self
,
path
):
current
=
self
.
root
for
path_component
in
path
.
split
(
'/'
):
for
path_component
in
self
.
_splitpath
(
path
):
if
type
(
current
)
is
not
_ObjectDict
:
return
None
node
=
current
.
get
(
path_component
,
None
)
if
node
is
None
:
return
None
current
=
node
return
node
return
current
def
__setitem__
(
self
,
path
,
object
):
if
not
path
:
raise
IndexError
(
"No path supplied"
)
current
=
self
.
root
path
,
name
=
path
.
rsplit
(
'/'
,
1
)
for
path_component
in
path
.
split
(
'/'
):
for
path_component
in
self
.
_splitpath
(
path
):
node
=
current
.
get
(
path_component
,
None
)
if
type
(
node
)
is
not
_ObjectDict
:
new_dict
=
_ObjectDict
()
...
...
@@ -57,6 +60,21 @@ class ObjectTree(object):
return
default
return
node
def
partialget
(
self
,
path
,
default
=
None
):
current
=
self
.
root
partial_path
=
[]
remaining_path
=
self
.
_splitpath
(
path
)
for
path_component
in
remaining_path
[:]:
if
type
(
current
)
is
not
_ObjectDict
:
return
"/"
.
join
(
partial_path
),
current
,
"/"
.
join
(
remaining_path
)
partial_path
.
append
(
path_component
)
remaining_path
.
pop
(
0
)
node
=
current
.
get
(
path_component
,
None
)
if
node
is
None
:
return
None
,
default
,
None
current
=
node
return
path
,
current
,
""
def
isobject
(
self
,
path
):
node
=
self
.
_locate
(
path
)
return
type
(
node
)
is
not
_ObjectDict
...
...
@@ -87,6 +105,8 @@ if __name__ == "__main__":
print
ot
[
'a/b/c'
]
print
ot
.
partialget
(
"/a/b/c/d/e/f"
)
ot
[
'a/b/c/d'
]
=
"?"
print
ot
[
'a/b/c'
]
.
keys
()
\ No newline at end of file
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