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
c638a2e9
Commit
c638a2e9
authored
Mar 20, 2011
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Opener fixes
parent
929c9603
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
10 deletions
+12
-10
fs/httpfs.py
+5
-1
fs/multifs.py
+3
-6
fs/opener.py
+4
-3
No files found.
fs/httpfs.py
View file @
c638a2e9
...
@@ -9,6 +9,7 @@ from fs.base import FS
...
@@ -9,6 +9,7 @@ from fs.base import FS
from
fs.path
import
normpath
from
fs.path
import
normpath
from
fs.errors
import
ResourceNotFoundError
,
UnsupportedError
from
fs.errors
import
ResourceNotFoundError
,
UnsupportedError
from
urllib2
import
urlopen
,
URLError
from
urllib2
import
urlopen
,
URLError
from
fs.filelike
import
FileWrapper
class
HTTPFS
(
FS
):
class
HTTPFS
(
FS
):
...
@@ -20,6 +21,9 @@ class HTTPFS(FS):
...
@@ -20,6 +21,9 @@ class HTTPFS(FS):
"""
"""
_meta
=
{
'read_only'
:
True
,
'network'
:
True
,}
def
__init__
(
self
,
url
):
def
__init__
(
self
,
url
):
"""
"""
...
@@ -46,7 +50,7 @@ class HTTPFS(FS):
...
@@ -46,7 +50,7 @@ class HTTPFS(FS):
except
OSError
,
e
:
except
OSError
,
e
:
raise
ResourceNotFoundError
(
path
,
details
=
e
)
raise
ResourceNotFoundError
(
path
,
details
=
e
)
return
f
return
FileWrapper
(
f
)
def
exists
(
self
,
path
):
def
exists
(
self
,
path
):
return
self
.
isfile
(
path
)
return
self
.
isfile
(
path
)
...
...
fs/multifs.py
View file @
c638a2e9
...
@@ -62,11 +62,10 @@ you can always access them directly.
...
@@ -62,11 +62,10 @@ you can always access them directly.
"""
"""
from
fs.base
import
FS
,
FSError
,
synchronize
from
fs.base
import
FS
,
synchronize
from
fs.path
import
*
from
fs.path
import
*
from
fs.errors
import
*
from
fs.errors
import
*
from
fs
import
_thread_synchronize_default
from
fs
import
_thread_synchronize_default
from
fs.errors
import
ResourceNotFoundError
class
MultiFS
(
FS
):
class
MultiFS
(
FS
):
...
@@ -234,7 +233,7 @@ class MultiFS(FS):
...
@@ -234,7 +233,7 @@ class MultiFS(FS):
for
fs
in
self
:
for
fs
in
self
:
try
:
try
:
paths
+=
fs
.
listdir
(
path
,
*
args
,
**
kwargs
)
paths
+=
fs
.
listdir
(
path
,
*
args
,
**
kwargs
)
except
FSError
,
e
:
except
FSError
:
pass
pass
return
list
(
set
(
paths
))
return
list
(
set
(
paths
))
...
@@ -254,16 +253,14 @@ class MultiFS(FS):
...
@@ -254,16 +253,14 @@ class MultiFS(FS):
@synchronize
@synchronize
def
rename
(
self
,
src
,
dst
):
def
rename
(
self
,
src
,
dst
):
if
self
.
writefs
is
None
:
if
self
.
writefs
is
None
:
raise
OperationFailedError
(
'rename'
,
path
=
path
,
msg
=
"No writeable FS set"
)
raise
OperationFailedError
(
'rename'
,
path
=
src
,
msg
=
"No writeable FS set"
)
self
.
writefs
.
rename
(
src
,
dst
)
self
.
writefs
.
rename
(
src
,
dst
)
raise
ResourceNotFoundError
(
path
)
@synchronize
@synchronize
def
settimes
(
self
,
path
,
accessed_time
=
None
,
modified_time
=
None
):
def
settimes
(
self
,
path
,
accessed_time
=
None
,
modified_time
=
None
):
if
self
.
writefs
is
None
:
if
self
.
writefs
is
None
:
raise
OperationFailedError
(
'settimes'
,
path
=
path
,
msg
=
"No writeable FS set"
)
raise
OperationFailedError
(
'settimes'
,
path
=
path
,
msg
=
"No writeable FS set"
)
self
.
writefs
.
settimes
(
path
,
accessed_time
,
modified_time
)
self
.
writefs
.
settimes
(
path
,
accessed_time
,
modified_time
)
raise
ResourceNotFoundError
(
path
)
@synchronize
@synchronize
def
getinfo
(
self
,
path
):
def
getinfo
(
self
,
path
):
...
...
fs/opener.py
View file @
c638a2e9
...
@@ -231,6 +231,7 @@ class OpenerRegistry(object):
...
@@ -231,6 +231,7 @@ class OpenerRegistry(object):
fs_path
=
join
(
fs_path
,
path
)
fs_path
=
join
(
fs_path
,
path
)
if
create_dir
and
fs_path
:
if
create_dir
and
fs_path
:
if
not
fs
.
getmeta
(
'read_only'
,
False
):
fs
.
makedir
(
fs_path
,
allow_recreate
=
True
)
fs
.
makedir
(
fs_path
,
allow_recreate
=
True
)
pathname
,
resourcename
=
pathsplit
(
fs_path
or
''
)
pathname
,
resourcename
=
pathsplit
(
fs_path
or
''
)
...
@@ -659,7 +660,7 @@ example:
...
@@ -659,7 +660,7 @@ example:
def
get_fs
(
cls
,
registry
,
fs_name
,
fs_name_params
,
fs_path
,
writeable
,
create_dir
):
def
get_fs
(
cls
,
registry
,
fs_name
,
fs_name_params
,
fs_path
,
writeable
,
create_dir
):
from
fs.httpfs
import
HTTPFS
from
fs.httpfs
import
HTTPFS
if
'/'
in
fs_path
:
if
'/'
in
fs_path
:
dirname
,
resourcename
=
fs_path
.
rsplit
(
'/'
)
dirname
,
resourcename
=
fs_path
.
rsplit
(
'/'
,
1
)
else
:
else
:
dirname
=
fs_path
dirname
=
fs_path
resourcename
=
''
resourcename
=
''
...
@@ -796,7 +797,7 @@ example:
...
@@ -796,7 +797,7 @@ example:
mount_fs
=
MountFS
()
mount_fs
=
MountFS
()
for
mount_point
,
mount_path
in
cfg
.
items
(
section
):
for
mount_point
,
mount_path
in
cfg
.
items
(
section
):
mount_fs
.
mount
(
mount_point
,
registry
.
opendir
(
mount_path
))
mount_fs
.
mount
(
mount_point
,
registry
.
opendir
(
mount_path
,
create_dir
=
create_dir
))
return
mount_fs
,
''
return
mount_fs
,
''
...
@@ -832,7 +833,7 @@ example:
...
@@ -832,7 +833,7 @@ example:
multi_fs
=
MultiFS
()
multi_fs
=
MultiFS
()
for
name
,
fs_url
in
cfg
.
items
(
section
):
for
name
,
fs_url
in
cfg
.
items
(
section
):
multi_fs
.
addfs
(
name
,
registry
.
opendir
(
fs_url
))
multi_fs
.
addfs
(
name
,
registry
.
opendir
(
fs_url
,
create_dir
=
create_dir
))
return
multi_fs
,
''
return
multi_fs
,
''
...
...
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