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
01b2fd2e
Commit
01b2fd2e
authored
Sep 27, 2010
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
raise ResourceInvalidError when open() is called on a directory
parent
18e4fae2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
4 deletions
+16
-4
fs/memoryfs.py
+3
-2
fs/osfs/__init__.py
+9
-2
fs/tests/__init__.py
+4
-0
No files found.
fs/memoryfs.py
View file @
01b2fd2e
...
...
@@ -340,6 +340,8 @@ class MemoryFS(FS):
raise
ResourceNotFoundError
(
path
)
file_dir_entry
=
parent_dir_entry
.
contents
[
filename
]
if
file_dir_entry
.
isdir
():
raise
ResourceInvalidError
(
path
)
if
'a'
in
mode
:
if
file_dir_entry
.
islocked
():
...
...
@@ -567,4 +569,4 @@ class MemoryFS(FS):
@synchronize
def
listxattrs
(
self
,
path
):
dir_entry
=
self
.
_dir_entry
(
path
)
return
dir_entry
.
xattrs
.
keys
()
\ No newline at end of file
return
dir_entry
.
xattrs
.
keys
()
fs/osfs/__init__.py
View file @
01b2fd2e
...
...
@@ -149,7 +149,14 @@ class OSFS(OSFSXAttrMixin, OSFSWatchMixin, FS):
@convert_os_errors
def
open
(
self
,
path
,
mode
=
"r"
,
**
kwargs
):
mode
=
filter
(
lambda
c
:
c
in
"rwabt+"
,
mode
)
return
open
(
self
.
getsyspath
(
path
),
mode
,
kwargs
.
get
(
"buffering"
,
-
1
))
sys_path
=
self
.
getsyspath
(
path
)
try
:
return
open
(
sys_path
,
mode
,
kwargs
.
get
(
"buffering"
,
-
1
))
except
EnvironmentError
,
e
:
# Win32 gives EACCES when opening a directory.
if
sys
.
platform
==
"win32"
and
e
.
errno
in
(
errno
.
EACCES
,):
raise
ResourceInvalidError
(
path
)
raise
@convert_os_errors
def
exists
(
self
,
path
):
...
...
@@ -246,7 +253,7 @@ class OSFS(OSFSXAttrMixin, OSFSWatchMixin, FS):
# a directory that doesn't exist. We want ParentMissingError
# in this case.
if
e
.
errno
==
errno
.
ENOENT
:
if
not
os
.
path
.
exists
(
dirname
(
path_dst
)):
if
not
os
.
path
.
exists
(
os
.
path
.
dirname
(
path_dst
)):
raise
ParentDirectoryMissingError
(
dst
)
raise
...
...
fs/tests/__init__.py
View file @
01b2fd2e
...
...
@@ -68,6 +68,10 @@ class FSTestCases(object):
repr
(
self
.
fs
)
self
.
assert_
(
hasattr
(
self
.
fs
,
'desc'
))
def
test_open_on_directory
(
self
):
self
.
fs
.
makedir
(
"testdir"
)
self
.
assertRaises
(
ResourceInvalidError
,
self
.
fs
.
open
,
"testdir"
)
def
test_writefile
(
self
):
self
.
assertRaises
(
ResourceNotFoundError
,
self
.
fs
.
open
,
"test1.txt"
)
f
=
self
.
fs
.
open
(
"test1.txt"
,
"w"
)
...
...
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