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
60e6eff7
Commit
60e6eff7
authored
Sep 04, 2008
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work in progress
parent
41f626a4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
53 deletions
+18
-53
fs/browsewin.py
+2
-2
fs/fs.py
+11
-31
fs/memoryfs.py
+1
-3
fs/osfs.py
+0
-8
fs/tests.py
+2
-4
fs/utils.py
+2
-5
No files found.
fs/browsewin.py
View file @
60e6eff7
...
@@ -8,7 +8,7 @@ import fs
...
@@ -8,7 +8,7 @@ import fs
class
InfoFrame
(
wx
.
Frame
):
class
InfoFrame
(
wx
.
Frame
):
def
__init__
(
self
,
path
,
desc
,
info
):
def
__init__
(
self
,
path
,
desc
,
info
):
wx
.
Frame
.
__init__
(
self
,
None
,
-
1
,
style
=
wx
.
DEFAULT_FRAME_STYLE
,
size
=
(
7
00
,
500
))
wx
.
Frame
.
__init__
(
self
,
None
,
-
1
,
style
=
wx
.
DEFAULT_FRAME_STYLE
,
size
=
(
5
00
,
500
))
self
.
SetTitle
(
"FS Object info -
%
s (
%
s)"
%
(
path
,
desc
))
self
.
SetTitle
(
"FS Object info -
%
s (
%
s)"
%
(
path
,
desc
))
...
@@ -20,7 +20,7 @@ class InfoFrame(wx.Frame):
...
@@ -20,7 +20,7 @@ class InfoFrame(wx.Frame):
self
.
list_ctrl
.
InsertColumn
(
0
,
"Key"
)
self
.
list_ctrl
.
InsertColumn
(
0
,
"Key"
)
self
.
list_ctrl
.
InsertColumn
(
1
,
"Value"
)
self
.
list_ctrl
.
InsertColumn
(
1
,
"Value"
)
self
.
list_ctrl
.
SetColumnWidth
(
0
,
1
5
0
)
self
.
list_ctrl
.
SetColumnWidth
(
0
,
1
9
0
)
self
.
list_ctrl
.
SetColumnWidth
(
1
,
300
)
self
.
list_ctrl
.
SetColumnWidth
(
1
,
300
)
for
key
in
keys
:
for
key
in
keys
:
...
...
fs/fs.py
View file @
60e6eff7
...
@@ -25,6 +25,7 @@ error_msgs = {
...
@@ -25,6 +25,7 @@ error_msgs = {
"DIR_EXISTS"
:
"Directory exists (try allow_recreate=True):
%(path)
s"
,
"DIR_EXISTS"
:
"Directory exists (try allow_recreate=True):
%(path)
s"
,
"REMOVE_FAILED"
:
"Unable to remove file:
%(path)
s"
,
"REMOVE_FAILED"
:
"Unable to remove file:
%(path)
s"
,
"REMOVEDIR_FAILED"
:
"Unable to remove dir:
%(path)
s"
,
"REMOVEDIR_FAILED"
:
"Unable to remove dir:
%(path)
s"
,
"GETSIZE_FAILED"
:
"Unable to retrieve size of resource:
%(path)
s"
,
# NoSysPathError
# NoSysPathError
"NO_SYS_PATH"
:
"No mapping to OS filesytem:
%(path)
s,"
,
"NO_SYS_PATH"
:
"No mapping to OS filesytem:
%(path)
s,"
,
...
@@ -487,7 +488,16 @@ class FS(object):
...
@@ -487,7 +488,16 @@ class FS(object):
def
getsize
(
self
,
path
):
def
getsize
(
self
,
path
):
return
self
.
getinfo
(
path
)[
'size'
]
"""Returns the size (in bytes) of a resource.
path -- A path to the resource
"""
info
=
self
.
getinfo
(
path
)
size
=
info
.
get
(
'size'
,
None
)
if
'size'
is
None
:
raise
OperationFailedError
(
"GETSIZE_FAILED"
,
path
)
return
size
...
@@ -576,36 +586,6 @@ class SubFS(FS):
...
@@ -576,36 +586,6 @@ class SubFS(FS):
def
rename
(
self
,
src
,
dst
):
def
rename
(
self
,
src
,
dst
):
return
self
.
parent
.
rename
(
self
.
_delegate
(
src
),
self
.
_delegate
(
dst
))
return
self
.
parent
.
rename
(
self
.
_delegate
(
src
),
self
.
_delegate
(
dst
))
def
validatefs
(
fs
):
expected_methods
=
[
"abspath"
,
"getsyspath"
,
"open"
,
"exists"
,
"isdir"
,
"isfile"
,
"ishidden"
,
"listdir"
,
"makedir"
,
"remove"
,
"removedir"
,
"getinfo"
,
"getsize"
,
"rename"
,
]
pad_size
=
len
(
max
(
expected_methods
,
key
=
str
.
__len__
))
count
=
0
for
method_name
in
sorted
(
expected_methods
):
method
=
getattr
(
fs
,
method_name
,
None
)
if
method
is
None
:
print
method_name
.
ljust
(
pad_size
),
'?'
else
:
print
method_name
.
ljust
(
pad_size
),
'X'
count
+=
1
print
print
"
%
i out of
%
i methods"
%
(
count
,
len
(
expected_methods
))
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
import
osfs
import
osfs
...
...
fs/memoryfs.py
View file @
60e6eff7
...
@@ -411,9 +411,7 @@ class MemoryFS(FS):
...
@@ -411,9 +411,7 @@ class MemoryFS(FS):
dir_entry
=
self
.
_get_dir_entry
(
path
)
dir_entry
=
self
.
_get_dir_entry
(
path
)
if
dir_entry
is
None
:
if
dir_entry
is
None
:
raise
ResourceNotFoundError
(
"NO_DIR"
,
path
)
raise
ResourceNotFoundError
(
"NO_DIR"
,
path
)
paths
=
dir_entry
.
contents
.
keys
()
paths
=
dir_entry
.
contents
.
keys
()
print
"Listdir"
,
paths
return
self
.
_listdir_helper
(
path
,
paths
,
wildcard
,
full
,
absolute
,
hidden
,
dirs_only
,
files_only
)
return
self
.
_listdir_helper
(
path
,
paths
,
wildcard
,
full
,
absolute
,
hidden
,
dirs_only
,
files_only
)
finally
:
finally
:
self
.
_lock
.
release
()
self
.
_lock
.
release
()
...
...
fs/osfs.py
View file @
60e6eff7
...
@@ -140,14 +140,6 @@ class OSFS(FS):
...
@@ -140,14 +140,6 @@ class OSFS(FS):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
osfs
=
OSFS
(
"~/projects"
)
osfs
=
OSFS
(
"~/projects"
)
print
osfs
for
filename
in
osfs
.
walkfiles
(
"/"
,
"*.pov"
):
print
filename
print
osfs
.
getinfo
(
filename
)
validatefs
(
osfs
)
import
browsewin
import
browsewin
browsewin
.
browse
(
osfs
)
browsewin
.
browse
(
osfs
)
...
...
fs/tests.py
View file @
60e6eff7
...
@@ -247,15 +247,13 @@ class TestOSFS(unittest.TestCase):
...
@@ -247,15 +247,13 @@ class TestOSFS(unittest.TestCase):
info
=
self
.
fs
.
getinfo
(
"info.txt"
)
info
=
self
.
fs
.
getinfo
(
"info.txt"
)
self
.
assertEqual
(
info
[
'size'
],
len
(
test_str
))
self
.
assertEqual
(
info
[
'size'
],
len
(
test_str
))
def
test_getsize
(
self
):
def
test_getsize
(
self
):
test_str
=
"*"
*
23
test_str
=
"*"
*
23
f
=
self
.
fs
.
open
(
"info.txt"
,
'wb'
)
f
=
self
.
fs
.
open
(
"info.txt"
,
'wb'
)
f
.
write
(
test_str
)
f
.
write
(
test_str
)
f
.
close
()
f
.
close
()
info
=
self
.
fs
.
getinfo
(
"info.txt"
)
size
=
self
.
fs
.
getsize
(
"info.txt"
)
self
.
assertEqual
(
info
[
'size'
]
,
len
(
test_str
))
self
.
assertEqual
(
size
,
len
(
test_str
))
class
TestSubFS
(
TestOSFS
):
class
TestSubFS
(
TestOSFS
):
...
...
fs/utils.py
View file @
60e6eff7
...
@@ -10,7 +10,7 @@ def copy_file(src_fs, src_path, dst_fs, dst_path, chunk_size=1024*16):
...
@@ -10,7 +10,7 @@ def copy_file(src_fs, src_path, dst_fs, dst_path, chunk_size=1024*16):
dst_fs -- Destination filesystem object
dst_fs -- Destination filesystem object
dst_path -- Destination filesystem object
dst_path -- Destination filesystem object
chunk_size -- Size of chunks to move if system copyfile is not available (default 16K)
chunk_size -- Size of chunks to move if system copyfile is not available (default 16K)
"""
"""
src_syspath
=
src_fs
.
getsyspath
(
src_path
,
default
=
""
)
src_syspath
=
src_fs
.
getsyspath
(
src_path
,
default
=
""
)
...
@@ -48,7 +48,4 @@ def get_total_data(count_fs):
...
@@ -48,7 +48,4 @@ def get_total_data(count_fs):
"""
"""
total
=
0
total
=
sum
(
count_fs
.
getsize
(
f
)
for
f
in
count_fs
.
walkfiles
(
absolute
=
True
))
for
f
in
count_fs
.
walkfiles
(
absolute
=
True
):
total
+=
count_fs
.
getsize
(
f
)
return
total
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