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
9c879d04
Commit
9c879d04
authored
Dec 12, 2010
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Command fixes
parent
155f51dc
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
41 additions
and
42 deletions
+41
-42
fs/base.py
+2
-0
fs/commands/fscp.py
+0
-0
fs/commands/fsmkdir.py
+1
-0
fs/commands/fsmv.py
+1
-1
fs/commands/fsrm.py
+0
-0
fs/commands/fsserve.py
+7
-0
fs/commands/fstree.py
+1
-1
fs/commands/runner.py
+1
-3
fs/opener.py
+16
-20
fs/osfs/__init__.py
+0
-0
fs/rpcfs.py
+2
-5
fs/utils.py
+1
-8
fs/wrapfs/__init__.py
+6
-1
fs/wrapfs/subfs.py
+3
-3
No files found.
fs/base.py
View file @
9c879d04
...
@@ -649,6 +649,8 @@ class FS(object):
...
@@ -649,6 +649,8 @@ class FS(object):
:rtype: An FS object
:rtype: An FS object
"""
"""
if
path
in
(
''
,
'/'
):
return
self
from
fs.wrapfs.subfs
import
SubFS
from
fs.wrapfs.subfs
import
SubFS
if
not
self
.
exists
(
path
):
if
not
self
.
exists
(
path
):
raise
ResourceNotFoundError
(
path
)
raise
ResourceNotFoundError
(
path
)
...
...
fs/commands/fscp.py
View file @
9c879d04
fs/commands/fsmkdir.py
View file @
9c879d04
...
@@ -15,6 +15,7 @@ Make a directory"""
...
@@ -15,6 +15,7 @@ Make a directory"""
for
fs_url
in
args
:
for
fs_url
in
args
:
fs
,
path
=
self
.
open_fs
(
fs_url
,
create
=
True
)
fs
,
path
=
self
.
open_fs
(
fs_url
,
create
=
True
)
print
fs
,
path
def
run
():
def
run
():
return
FSMkdir
()
.
run
()
return
FSMkdir
()
.
run
()
...
...
fs/commands/fsmv.py
View file @
9c879d04
...
@@ -2,7 +2,7 @@ from fs.utils import movefile, contains_files
...
@@ -2,7 +2,7 @@ from fs.utils import movefile, contains_files
from
fs.commands
import
fscp
from
fs.commands
import
fscp
import
sys
import
sys
class
FSMove
(
fscp
.
FS
Copy
):
class
FSMove
(
fscp
.
FS
cp
):
usage
=
"""fsmv [OPTION]... [SOURCE] [DESTINATION]
usage
=
"""fsmv [OPTION]... [SOURCE] [DESTINATION]
Move files from SOURCE to DESTINATION"""
Move files from SOURCE to DESTINATION"""
...
...
fs/commands/fsrm.py
View file @
9c879d04
fs/commands/fsserve.py
View file @
9c879d04
...
@@ -30,6 +30,13 @@ Serves the contents of PATH with one of a number of methods"""
...
@@ -30,6 +30,13 @@ Serves the contents of PATH with one of a number of methods"""
fs
,
path
=
self
.
open_fs
(
fs_url
)
fs
,
path
=
self
.
open_fs
(
fs_url
)
if
fs
.
isdir
(
path
):
fs
=
fs
.
opendir
(
path
)
path
=
'/'
if
options
.
verbose
:
print
"Serving
\"
%
s
\"
in
%
s"
%
(
path
,
fs
)
port
=
options
.
port
port
=
options
.
port
try
:
try
:
...
...
fs/commands/fstree.py
View file @
9c879d04
...
@@ -13,7 +13,7 @@ Recursively display the contents of PATH in an ascii tree"""
...
@@ -13,7 +13,7 @@ Recursively display the contents of PATH in an ascii tree"""
def
get_optparse
(
self
):
def
get_optparse
(
self
):
optparse
=
super
(
FSTree
,
self
)
.
get_optparse
()
optparse
=
super
(
FSTree
,
self
)
.
get_optparse
()
optparse
.
add_option
(
'-
L
'
,
'--level'
,
dest
=
'depth'
,
type
=
"int"
,
default
=
5
,
optparse
.
add_option
(
'-
l
'
,
'--level'
,
dest
=
'depth'
,
type
=
"int"
,
default
=
5
,
help
=
"Descend only LEVEL directories deep"
,
metavar
=
"LEVEL"
)
help
=
"Descend only LEVEL directories deep"
,
metavar
=
"LEVEL"
)
optparse
.
add_option
(
'-a'
,
'--all'
,
dest
=
'all'
,
action
=
'store_true'
,
default
=
False
,
optparse
.
add_option
(
'-a'
,
'--all'
,
dest
=
'all'
,
action
=
'store_true'
,
default
=
False
,
help
=
"do not hide dot files"
)
help
=
"do not hide dot files"
)
...
...
fs/commands/runner.py
View file @
9c879d04
...
@@ -222,12 +222,10 @@ class Command(object):
...
@@ -222,12 +222,10 @@ class Command(object):
if
self
.
is_terminal
():
if
self
.
is_terminal
():
self
.
output
(
"
\n
"
)
self
.
output
(
"
\n
"
)
return
0
return
0
#except ValueError:
# pass
except
SystemExit
:
except
SystemExit
:
return
0
return
0
except
Exception
,
e
:
except
Exception
,
e
:
self
.
error
(
self
.
wrap_error
(
'
Internal
Error -
%
s
\n
'
%
unicode
(
e
)))
self
.
error
(
self
.
wrap_error
(
'Error -
%
s
\n
'
%
unicode
(
e
)))
return
1
return
1
...
...
fs/opener.py
View file @
9c879d04
...
@@ -79,7 +79,7 @@ class OpenerRegistry(object):
...
@@ -79,7 +79,7 @@ class OpenerRegistry(object):
for
name
in
opener
.
names
:
for
name
in
opener
.
names
:
self
.
registry
[
name
]
=
index
self
.
registry
[
name
]
=
index
def
parse
(
self
,
fs_url
,
default_fs_name
=
None
,
writeable
=
False
,
create
=
False
):
def
parse
(
self
,
fs_url
,
default_fs_name
=
None
,
open_dir
=
True
,
writeable
=
False
,
create
=
False
):
orig_url
=
fs_url
orig_url
=
fs_url
match
=
self
.
split_segments
(
fs_url
)
match
=
self
.
split_segments
(
fs_url
)
...
@@ -110,24 +110,24 @@ class OpenerRegistry(object):
...
@@ -110,24 +110,24 @@ class OpenerRegistry(object):
if
fs_url
is
None
:
if
fs_url
is
None
:
raise
OpenerError
(
"Unable to parse '
%
s'"
%
orig_url
)
raise
OpenerError
(
"Unable to parse '
%
s'"
%
orig_url
)
#wildcard = None
#if iswildcard(fs_url):
# fs_url, wildcard = pathsplit(fs_url)
fs
,
fs_path
=
opener
.
get_fs
(
self
,
fs_name
,
fs_name_params
,
fs_url
,
writeable
,
create
)
fs
,
fs_path
=
opener
.
get_fs
(
self
,
fs_name
,
fs_name_params
,
fs_url
,
writeable
,
create
)
if
fs_path
and
iswildcard
(
fs_path
):
pathname
,
resourcename
=
pathsplit
(
fs_path
or
''
)
pathname
,
resourcename
=
pathsplit
(
fs_path
or
''
)
if
pathname
:
if
pathname
:
fs
=
fs
.
opendir
(
pathname
)
fs
=
fs
.
opendir
(
pathname
)
fs_path
=
resourcename
return
fs
,
resourcename
if
fs_path
and
iswildcard
(
fs_path
):
#pathname, resourcename = pathsplit(fs_path or '')
return
fs
,
fs_path
#if pathname and resourcename:
# fs = fs.opendir(pathname)
# fs_path = resourcename
fs_path
=
join
(
fs_path
,
path
)
fs_path
=
join
(
fs_path
,
path
)
pathname
,
resourcename
=
pathsplit
(
fs_path
or
''
)
pathname
,
resourcename
=
pathsplit
(
fs_path
or
''
)
if
pathname
:
if
pathname
and
resourcename
:
fs
=
fs
.
opendir
(
pathname
)
fs
=
fs
.
opendir
(
pathname
)
fs_path
=
resourcename
fs_path
=
resourcename
...
@@ -180,17 +180,12 @@ class OSFSOpener(Opener):
...
@@ -180,17 +180,12 @@ class OSFSOpener(Opener):
from
fs.osfs
import
OSFS
from
fs.osfs
import
OSFS
path
=
_expand_syspath
(
fs_path
)
path
=
_expand_syspath
(
fs_path
)
if
create
:
if
create
and
not
os
.
path
.
exists
(
path
)
:
from
fs.osfs
import
_os_makedirs
from
fs.osfs
import
_os_makedirs
_os_makedirs
(
fs_path
)
_os_makedirs
(
path
)
if
os
.
path
.
isdir
(
path
):
dirname
,
resourcename
=
pathsplit
(
fs_path
)
osfs
=
OSFS
(
path
)
osfs
=
OSFS
(
dirname
)
filepath
=
None
return
osfs
,
resourcename
else
:
path
,
filepath
=
pathsplit
(
path
)
osfs
=
OSFS
(
path
,
create
=
create
)
return
osfs
,
filepath
class
ZipOpener
(
Opener
):
class
ZipOpener
(
Opener
):
names
=
[
'zip'
,
'zip64'
]
names
=
[
'zip'
,
'zip64'
]
...
@@ -212,7 +207,6 @@ class ZipOpener(Opener):
...
@@ -212,7 +207,6 @@ class ZipOpener(Opener):
zip_file
=
zip_fs
.
open
(
zip_path
,
mode
=
open_mode
)
zip_file
=
zip_fs
.
open
(
zip_path
,
mode
=
open_mode
)
username
,
password
,
fs_path
=
registry
.
parse_credentials
(
fs_path
)
username
,
password
,
fs_path
=
registry
.
parse_credentials
(
fs_path
)
from
fs.zipfs
import
ZipFS
from
fs.zipfs
import
ZipFS
...
@@ -387,7 +381,9 @@ opener = OpenerRegistry([OSFSOpener,
...
@@ -387,7 +381,9 @@ opener = OpenerRegistry([OSFSOpener,
def
main
():
def
main
():
fs
,
path
=
opener
.
parse
(
'zip:zip://~/zips.zip!t.zip!'
)
#fs, path = opener.parse('zip:zip://~/zips.zip!t.zip!')
fs
,
path
=
opener
.
parse
(
'rpc://127.0.0.1/a/*.JPG'
)
print
fs
,
path
print
fs
,
path
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
fs/osfs/__init__.py
View file @
9c879d04
fs/rpcfs.py
View file @
9c879d04
...
@@ -34,14 +34,11 @@ def re_raise_faults(func):
...
@@ -34,14 +34,11 @@ def re_raise_faults(func):
bits
=
" "
.
join
(
bits
[
1
:])
.
split
(
">:"
)
bits
=
" "
.
join
(
bits
[
1
:])
.
split
(
">:"
)
cls
=
bits
[
0
]
cls
=
bits
[
0
]
msg
=
">:"
.
join
(
bits
[
1
:])
msg
=
">:"
.
join
(
bits
[
1
:])
while
cls
[
0
]
in
[
"'"
,
'"'
]:
cls
=
cls
.
strip
(
'
\'
'
)
cls
=
cls
[
1
:]
while
cls
[
-
1
]
in
[
"'"
,
'"'
]:
cls
=
cls
[:
-
1
]
cls
=
_object_by_name
(
cls
)
cls
=
_object_by_name
(
cls
)
# Re-raise using the remainder of the fault code as message
# Re-raise using the remainder of the fault code as message
if
cls
:
if
cls
:
raise
cls
(
msg
)
raise
cls
(
msg
=
msg
)
raise
f
raise
f
except
socket
.
error
,
e
:
except
socket
.
error
,
e
:
raise
RemoteConnectionError
(
str
(
e
),
details
=
e
)
raise
RemoteConnectionError
(
str
(
e
),
details
=
e
)
...
...
fs/utils.py
View file @
9c879d04
...
@@ -56,9 +56,6 @@ def copyfile(src_fs, src_path, dst_fs, dst_path, overwrite=True, chunk_size=64*1
...
@@ -56,9 +56,6 @@ def copyfile(src_fs, src_path, dst_fs, dst_path, overwrite=True, chunk_size=64*1
src
=
None
src
=
None
try
:
try
:
# Chunk copy
# Chunk copy
if
src_fs
.
getsize
(
src_path
)
<
chunk_size
:
src
=
src_fs
.
getcontents
(
src_path
)
else
:
src
=
src_fs
.
open
(
src_path
,
'rb'
)
src
=
src_fs
.
open
(
src_path
,
'rb'
)
dst_fs
.
setcontents
(
dst_path
,
src
,
chunk_size
=
chunk_size
)
dst_fs
.
setcontents
(
dst_path
,
src
,
chunk_size
=
chunk_size
)
finally
:
finally
:
...
@@ -92,19 +89,15 @@ def movefile(src_fs, src_path, dst_fs, dst_path, overwrite=True, chunk_size=64*1
...
@@ -92,19 +89,15 @@ def movefile(src_fs, src_path, dst_fs, dst_path, overwrite=True, chunk_size=64*1
FS
.
_shutil_movefile
(
src_syspath
,
dst_syspath
)
FS
.
_shutil_movefile
(
src_syspath
,
dst_syspath
)
return
return
src
=
None
src
=
None
try
:
try
:
# Chunk copy
# Chunk copy
if
src_fs
.
getsize
(
src_path
)
<
chunk_size
:
src
=
src_fs
.
getcontents
(
src_path
)
else
:
src
=
src_fs
.
open
(
src_path
,
'rb'
)
src
=
src_fs
.
open
(
src_path
,
'rb'
)
dst_fs
.
setcontents
(
dst_path
,
src
,
chunk_size
=
chunk_size
)
dst_fs
.
setcontents
(
dst_path
,
src
,
chunk_size
=
chunk_size
)
src_fs
.
remove
(
src_path
)
finally
:
finally
:
if
src
is
not
None
and
hasattr
(
src
,
'close'
):
if
src
is
not
None
and
hasattr
(
src
,
'close'
):
src
.
close
()
src
.
close
()
src_fs
.
remove
(
src_path
)
def
movedir
(
fs1
,
fs2
,
overwrite
=
False
,
ignore_errors
=
False
,
chunk_size
=
64
*
1024
):
def
movedir
(
fs1
,
fs2
,
overwrite
=
False
,
ignore_errors
=
False
,
chunk_size
=
64
*
1024
):
"""Moves contents of a directory from one filesystem to another.
"""Moves contents of a directory from one filesystem to another.
...
...
fs/wrapfs/__init__.py
View file @
9c879d04
...
@@ -164,7 +164,12 @@ class WrapFS(FS):
...
@@ -164,7 +164,12 @@ class WrapFS(FS):
return
self
.
wrapped_fs
.
isfile
(
self
.
_encode
(
path
))
return
self
.
wrapped_fs
.
isfile
(
self
.
_encode
(
path
))
@rewrite_errors
@rewrite_errors
def
listdir
(
self
,
path
=
""
,
**
kwds
):
def
listdir
(
self
,
path
=
""
,
wildcard
=
None
,
full
=
False
,
absolute
=
False
,
dirs_only
=
False
,
files_only
=
False
):
kwds
=
dict
(
wildcard
=
wildcard
,
full
=
full
,
absolute
=
absolute
,
dirs_only
=
dirs_only
,
files_only
=
files_only
)
full
=
kwds
.
pop
(
"full"
,
False
)
full
=
kwds
.
pop
(
"full"
,
False
)
absolute
=
kwds
.
pop
(
"absolute"
,
False
)
absolute
=
kwds
.
pop
(
"absolute"
,
False
)
wildcard
=
kwds
.
pop
(
"wildcard"
,
None
)
wildcard
=
kwds
.
pop
(
"wildcard"
,
None
)
...
...
fs/wrapfs/subfs.py
View file @
9c879d04
...
@@ -30,16 +30,16 @@ class SubFS(WrapFS):
...
@@ -30,16 +30,16 @@ class SubFS(WrapFS):
return
abspath
(
normpath
(
path
))[
len
(
self
.
sub_dir
):]
return
abspath
(
normpath
(
path
))[
len
(
self
.
sub_dir
):]
def
__str__
(
self
):
def
__str__
(
self
):
return
"
<SubFS:
%
s in
%
s>"
%
(
self
.
sub_dir
,
self
.
wrapped_fs
)
return
"
%
s/
%
s"
%
(
self
.
wrapped_fs
,
self
.
sub_dir
.
lstrip
(
'/'
)
)
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
u"
<SubFS:
%
s in
%
s>"
%
(
self
.
sub_dir
,
self
.
wrapped_fs
)
return
u"
%
s/
%
s"
%
(
self
.
wrapped_fs
,
self
.
sub_dir
.
lstrip
(
'/'
)
)
def
__repr__
(
self
):
def
__repr__
(
self
):
return
str
(
self
)
return
str
(
self
)
def
desc
(
self
,
path
):
def
desc
(
self
,
path
):
desc
=
"
%
s
in sub dir
%
s of
%
s"
%
(
path
,
self
.
sub_dir
,
str
(
self
.
wrapped_fs
)
)
desc
=
"
%
s
!
%
s"
%
(
str
(
self
),
path
)
return
desc
return
desc
def
setcontents
(
self
,
path
,
data
,
chunk_size
=
64
*
1024
):
def
setcontents
(
self
,
path
,
data
,
chunk_size
=
64
*
1024
):
...
...
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