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
cbcad9d0
Commit
cbcad9d0
authored
Sep 09, 2013
by
willmcgugan@gmail.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed signature for 'createfile' everywhere, fixes #133
parent
7465c77a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
8 deletions
+20
-8
fs/remote.py
+2
-2
fs/tests/__init__.py
+14
-2
fs/watch.py
+2
-2
fs/wrapfs/__init__.py
+2
-2
No files found.
fs/remote.py
View file @
cbcad9d0
...
...
@@ -679,8 +679,8 @@ class CacheFSMixin(FS):
self
.
__cache
[
path
]
=
CachedInfo
.
new_file_stub
()
return
res
def
createfile
(
self
,
path
):
super
(
CacheFSMixin
,
self
)
.
createfile
(
path
)
def
createfile
(
self
,
path
,
wipe
=
False
):
super
(
CacheFSMixin
,
self
)
.
createfile
(
path
,
wipe
=
wipe
)
with
self
.
__cache_lock
:
self
.
__cache
.
clear
(
path
)
self
.
__cache
[
path
]
=
CachedInfo
.
new_file_stub
()
...
...
fs/tests/__init__.py
View file @
cbcad9d0
...
...
@@ -136,6 +136,18 @@ class FSTestCases(object):
self
.
assertEquals
(
f
.
read
(),
b
(
"test file overwrite"
))
f
.
close
()
def
test_createfile
(
self
):
"""Test createfile"""
test
=
b
(
'now with content'
)
self
.
fs
.
createfile
(
"test.txt"
)
self
.
assert_
(
self
.
fs
.
exists
(
"test.txt"
))
self
.
assertEqual
(
self
.
fs
.
getcontents
(
"test.txt"
,
"rb"
),
b
(
''
))
self
.
fs
.
setcontents
(
"test.txt"
,
test
)
self
.
fs
.
createfile
(
"test.txt"
)
self
.
assertEqual
(
self
.
fs
.
getcontents
(
"test.txt"
,
"rb"
),
test
)
self
.
fs
.
createfile
(
"test.txt"
,
wipe
=
True
)
self
.
assertEqual
(
self
.
fs
.
getcontents
(
"test.txt"
,
"rb"
),
b
(
''
))
def
test_setcontents
(
self
):
# setcontents() should accept both a string...
self
.
fs
.
setcontents
(
"hello"
,
b
(
"world"
))
...
...
@@ -152,7 +164,7 @@ class FSTestCases(object):
b
(
"to you, good sir!"
)),
chunk_size
=
2
)
self
.
assertEquals
(
self
.
fs
.
getcontents
(
"hello"
,
"rb"
),
b
(
"to you, good sir!"
))
self
.
fs
.
setcontents
(
"hello"
,
""
,
"wb
"
)
self
.
fs
.
setcontents
(
"hello"
,
b
"
"
)
self
.
assertEquals
(
self
.
fs
.
getcontents
(
"hello"
,
"rb"
),
""
)
def
test_setcontents_async
(
self
):
...
...
@@ -888,7 +900,7 @@ class FSTestCases(object):
def
test_zero_read
(
self
):
"""Test read(0) returns empty string"""
self
.
fs
.
setcontents
(
'foo.txt'
,
b
(
'Hello, World'
)
,
'wb'
)
self
.
fs
.
setcontents
(
'foo.txt'
,
b
(
'Hello, World'
)
)
with
self
.
fs
.
open
(
'foo.txt'
,
'rb'
)
as
f
:
self
.
assert_
(
len
(
f
.
read
(
0
))
==
0
)
with
self
.
fs
.
open
(
'foo.txt'
,
'rt'
)
as
f
:
...
...
fs/watch.py
View file @
cbcad9d0
...
...
@@ -323,9 +323,9 @@ class WatchableFS(WatchableFSMixin,WrapFS):
self
.
notify_watchers
(
MODIFIED
,
path
,
True
)
return
ret
def
createfile
(
self
,
path
):
def
createfile
(
self
,
path
,
wipe
=
False
):
existed
=
self
.
wrapped_fs
.
isfile
(
path
)
ret
=
super
(
WatchableFS
,
self
)
.
createfile
(
path
)
ret
=
super
(
WatchableFS
,
self
)
.
createfile
(
path
,
wipe
=
False
)
if
not
existed
:
self
.
notify_watchers
(
CREATED
,
path
)
self
.
notify_watchers
(
ACCESSED
,
path
)
...
...
fs/wrapfs/__init__.py
View file @
cbcad9d0
...
...
@@ -167,8 +167,8 @@ class WrapFS(FS):
return
super
(
WrapFS
,
self
)
.
setcontents
(
path
,
data
,
encoding
=
encoding
,
errors
=
errors
,
chunk_size
=
chunk_size
)
@rewrite_errors
def
createfile
(
self
,
path
):
return
self
.
wrapped_fs
.
createfile
(
self
.
_encode
(
path
))
def
createfile
(
self
,
path
,
wipe
=
False
):
return
self
.
wrapped_fs
.
createfile
(
self
.
_encode
(
path
)
,
wipe
=
wipe
)
@rewrite_errors
def
exists
(
self
,
path
):
...
...
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