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
a143bd9a
Commit
a143bd9a
authored
Dec 14, 2010
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added --listopeners switch to commands
parent
a16c90b9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
3 deletions
+56
-3
fs/base.py
+1
-1
fs/commands/runner.py
+55
-2
fs/opener.py
+0
-0
No files found.
fs/base.py
View file @
a143bd9a
...
...
@@ -263,7 +263,7 @@ class FS(object):
:param allow_none: if True, this method will return None when there is no system path,
rather than raising NoSysPathError
:type allow_none: bool
:raises NoSysPathError:
I
f the path does not map on to a system path, and allow_none is set to False (default)
:raises NoSysPathError:
i
f the path does not map on to a system path, and allow_none is set to False (default)
:rtype: unicode
"""
...
...
fs/commands/runner.py
View file @
a143bd9a
...
...
@@ -95,7 +95,7 @@ class Command(object):
def
open_fs
(
self
,
fs_url
,
writeable
=
False
,
create
=
False
):
try
:
fs
,
path
=
opener
.
parse
(
fs_url
,
writeable
=
writeable
,
create
=
create
)
fs
,
path
=
opener
.
parse
(
fs_url
,
writeable
=
writeable
,
create
_dir
=
create
)
except
OpenerError
,
e
:
self
.
error
(
str
(
e
)
+
'
\n
'
)
sys
.
exit
(
1
)
...
...
@@ -204,19 +204,70 @@ class Command(object):
def
get_optparse
(
self
):
optparse
=
OptionParser
(
usage
=
self
.
usage
,
version
=
self
.
version
)
optparse
.
add_option
(
'--debug'
,
dest
=
'debug'
,
action
=
"store_true"
,
default
=
False
,
help
=
"Show debug information"
,
metavar
=
"DEBUG"
)
optparse
.
add_option
(
'-v'
,
'--verbose'
,
dest
=
'verbose'
,
action
=
"store_true"
,
default
=
False
,
help
=
"make output verbose"
,
metavar
=
"VERBOSE"
)
help
=
"make output verbose"
,
metavar
=
"VERBOSE"
)
optparse
.
add_option
(
'--listopeners'
,
dest
=
'listopeners'
,
action
=
"store_true"
,
default
=
False
,
help
=
"list all FS openers"
,
metavar
=
"LISTOPENERS"
)
return
optparse
def
list_openers
(
self
):
opener_table
=
[]
for
fs_opener
in
opener
.
openers
.
itervalues
():
names
=
fs_opener
.
names
desc
=
getattr
(
fs_opener
,
'desc'
,
''
)
opener_table
.
append
((
names
,
desc
))
opener_table
.
sort
(
key
=
lambda
r
:
r
[
0
])
def
wrap_line
(
text
):
lines
=
text
.
split
(
'
\n
'
)
for
line
in
lines
:
words
=
[]
line_len
=
0
for
word
in
line
.
split
():
if
line_len
+
len
(
word
)
>
self
.
terminal_width
:
self
.
output
(
' '
.
join
(
words
))
self
.
output
(
'
\n
'
)
del
words
[:]
line_len
=
0
words
.
append
(
word
)
line_len
+=
len
(
word
)
+
1
if
words
:
self
.
output
(
' '
.
join
(
words
))
self
.
output
(
'
\n
'
)
for
names
,
desc
in
opener_table
:
self
.
output
(
'
\n
'
)
proto
=
', '
.
join
([
n
+
'://'
for
n
in
names
])
self
.
output
(
self
.
wrap_dirname
(
'[
%
s]'
%
proto
))
self
.
output
(
'
\n
'
)
if
not
desc
.
strip
():
desc
=
"No information available"
wrap_line
(
desc
)
self
.
output
(
'
\n
'
)
def
run
(
self
):
parser
=
self
.
get_optparse
()
options
,
args
=
parser
.
parse_args
()
if
options
.
listopeners
:
self
.
list_openers
()
return
0
args
=
[
unicode
(
arg
,
sys
.
getfilesystemencoding
())
for
arg
in
args
]
self
.
verbose
=
options
.
verbose
try
:
return
self
.
do_run
(
options
,
args
)
or
0
except
FSError
,
e
:
self
.
error
(
self
.
wrap_error
(
unicode
(
e
))
+
'
\n
'
)
if
options
.
debug
:
raise
return
1
except
KeyboardInterrupt
:
if
self
.
is_terminal
():
...
...
@@ -226,6 +277,8 @@ class Command(object):
return
0
except
Exception
,
e
:
self
.
error
(
self
.
wrap_error
(
'Error -
%
s
\n
'
%
unicode
(
e
)))
if
options
.
debug
:
raise
return
1
...
...
fs/opener.py
View file @
a143bd9a
This diff is collapsed.
Click to expand it.
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