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
41efb9b7
Commit
41efb9b7
authored
Feb 26, 2014
by
willmcgugan@gmail.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test fixes
parent
ea7f6b43
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
21 additions
and
21 deletions
+21
-21
LICENSE.txt
+1
-1
fs/__init__.py
+1
-1
fs/errors.py
+4
-0
fs/expose/fuse/fuse3.py
+2
-1
fs/osfs/__init__.py
+9
-13
fs/tests/__init__.py
+2
-3
fs/watch.py
+2
-2
No files found.
LICENSE.txt
View file @
41efb9b7
Copyright (c) 2009-201
2
, Will McGugan <will@willmcgugan.com> and contributors.
Copyright (c) 2009-201
4
, Will McGugan <will@willmcgugan.com> and contributors.
All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
Redistribution and use in source and binary forms, with or without modification,
...
...
fs/__init__.py
View file @
41efb9b7
...
@@ -15,7 +15,7 @@ implementations of this interface such as:
...
@@ -15,7 +15,7 @@ implementations of this interface such as:
"""
"""
__version__
=
"0.
4.1
"
__version__
=
"0.
5.0-dev
"
__author__
=
"Will McGugan (will@willmcgugan.com)"
__author__
=
"Will McGugan (will@willmcgugan.com)"
# provide these by default so people can use 'fs.path.basename' etc.
# provide these by default so people can use 'fs.path.basename' etc.
...
...
fs/errors.py
View file @
41efb9b7
...
@@ -266,6 +266,10 @@ def convert_os_errors(func):
...
@@ -266,6 +266,10 @@ def convert_os_errors(func):
raise
OperationFailedError
(
opname
,
details
=
e
),
None
,
tb
raise
OperationFailedError
(
opname
,
details
=
e
),
None
,
tb
if
e
.
errno
==
errno
.
ENOENT
:
if
e
.
errno
==
errno
.
ENOENT
:
raise
ResourceNotFoundError
(
path
,
opname
=
opname
,
details
=
e
),
None
,
tb
raise
ResourceNotFoundError
(
path
,
opname
=
opname
,
details
=
e
),
None
,
tb
if
e
.
errno
==
errno
.
EFAULT
:
# This can happen when listdir a directory that is deleted by another thread
# Best to interpret it as a resource not found
raise
ResourceNotFoundError
(
path
,
opname
=
opname
,
details
=
e
),
None
,
tb
if
e
.
errno
==
errno
.
ESRCH
:
if
e
.
errno
==
errno
.
ESRCH
:
raise
ResourceNotFoundError
(
path
,
opname
=
opname
,
details
=
e
),
None
,
tb
raise
ResourceNotFoundError
(
path
,
opname
=
opname
,
details
=
e
),
None
,
tb
if
e
.
errno
==
errno
.
ENOTEMPTY
:
if
e
.
errno
==
errno
.
ENOTEMPTY
:
...
...
fs/expose/fuse/fuse3.py
View file @
41efb9b7
...
@@ -415,6 +415,7 @@ class FUSE(object):
...
@@ -415,6 +415,7 @@ class FUSE(object):
for
item
in
self
.
operations
(
'readdir'
,
path
,
fip
.
contents
.
fh
):
for
item
in
self
.
operations
(
'readdir'
,
path
,
fip
.
contents
.
fh
):
if
isinstance
(
item
,
str
):
if
isinstance
(
item
,
str
):
name
,
st
,
offset
=
item
,
None
,
0
name
,
st
,
offset
=
item
,
None
,
0
name
=
name
.
encode
(
'utf-8'
)
else
:
else
:
name
,
attrs
,
offset
=
item
name
,
attrs
,
offset
=
item
if
attrs
:
if
attrs
:
...
@@ -422,7 +423,7 @@ class FUSE(object):
...
@@ -422,7 +423,7 @@ class FUSE(object):
set_st_attrs
(
st
,
attrs
)
set_st_attrs
(
st
,
attrs
)
else
:
else
:
st
=
None
st
=
None
if
filler
(
buf
,
name
.
encode
(
'utf-8'
)
,
st
,
offset
)
!=
0
:
if
filler
(
buf
,
name
,
st
,
offset
)
!=
0
:
break
break
return
0
return
0
...
...
fs/osfs/__init__.py
View file @
41efb9b7
...
@@ -21,6 +21,7 @@ import errno
...
@@ -21,6 +21,7 @@ import errno
import
datetime
import
datetime
import
platform
import
platform
import
io
import
io
import
shutil
from
fs.base
import
*
from
fs.base
import
*
from
fs.path
import
*
from
fs.path
import
*
...
@@ -246,7 +247,9 @@ class OSFS(OSFSXAttrMixin, OSFSWatchMixin, FS):
...
@@ -246,7 +247,9 @@ class OSFS(OSFSXAttrMixin, OSFSWatchMixin, FS):
@convert_os_errors
@convert_os_errors
def
listdir
(
self
,
path
=
"./"
,
wildcard
=
None
,
full
=
False
,
absolute
=
False
,
dirs_only
=
False
,
files_only
=
False
):
def
listdir
(
self
,
path
=
"./"
,
wildcard
=
None
,
full
=
False
,
absolute
=
False
,
dirs_only
=
False
,
files_only
=
False
):
_decode_path
=
self
.
_decode_path
_decode_path
=
self
.
_decode_path
paths
=
[
_decode_path
(
p
)
for
p
in
os
.
listdir
(
self
.
getsyspath
(
path
))]
sys_path
=
self
.
getsyspath
(
path
)
listing
=
os
.
listdir
(
sys_path
)
paths
=
[
_decode_path
(
p
)
for
p
in
listing
]
return
self
.
_listdir_helper
(
path
,
paths
,
wildcard
,
full
,
absolute
,
dirs_only
,
files_only
)
return
self
.
_listdir_helper
(
path
,
paths
,
wildcard
,
full
,
absolute
,
dirs_only
,
files_only
)
@convert_os_errors
@convert_os_errors
...
@@ -283,21 +286,14 @@ class OSFS(OSFSXAttrMixin, OSFSWatchMixin, FS):
...
@@ -283,21 +286,14 @@ class OSFS(OSFSXAttrMixin, OSFSWatchMixin, FS):
@convert_os_errors
@convert_os_errors
def
removedir
(
self
,
path
,
recursive
=
False
,
force
=
False
):
def
removedir
(
self
,
path
,
recursive
=
False
,
force
=
False
):
sys_path
=
self
.
getsyspath
(
path
)
if
force
:
for
path2
in
self
.
listdir
(
path
,
absolute
=
True
,
files_only
=
True
):
try
:
self
.
remove
(
path2
)
except
ResourceNotFoundError
:
pass
for
path2
in
self
.
listdir
(
path
,
absolute
=
True
,
dirs_only
=
True
):
try
:
self
.
removedir
(
path2
,
force
=
True
)
except
ResourceNotFoundError
:
pass
# Don't remove the root directory of this FS
# Don't remove the root directory of this FS
if
path
in
(
''
,
'/'
):
if
path
in
(
''
,
'/'
):
raise
RemoveRootError
(
path
)
raise
RemoveRootError
(
path
)
sys_path
=
self
.
getsyspath
(
path
)
if
force
:
# shutil implementation handles concurrency better
shutil
.
rmtree
(
sys_path
,
ignore_errors
=
True
)
else
:
os
.
rmdir
(
sys_path
)
os
.
rmdir
(
sys_path
)
# Using os.removedirs() for this can result in dirs being
# Using os.removedirs() for this can result in dirs being
# removed outside the root of this FS, so we recurse manually.
# removed outside the root of this FS, so we recurse manually.
...
...
fs/tests/__init__.py
View file @
41efb9b7
...
@@ -137,7 +137,6 @@ class FSTestCases(object):
...
@@ -137,7 +137,6 @@ class FSTestCases(object):
f
.
close
()
f
.
close
()
def
test_createfile
(
self
):
def
test_createfile
(
self
):
"""Test createfile"""
test
=
b
(
'now with content'
)
test
=
b
(
'now with content'
)
self
.
fs
.
createfile
(
"test.txt"
)
self
.
fs
.
createfile
(
"test.txt"
)
self
.
assert_
(
self
.
fs
.
exists
(
"test.txt"
))
self
.
assert_
(
self
.
fs
.
exists
(
"test.txt"
))
...
@@ -396,8 +395,8 @@ class FSTestCases(object):
...
@@ -396,8 +395,8 @@ class FSTestCases(object):
alpha
=
u"
\N{GREEK SMALL LETTER ALPHA}
"
alpha
=
u"
\N{GREEK SMALL LETTER ALPHA}
"
beta
=
u"
\N{GREEK SMALL LETTER BETA}
"
beta
=
u"
\N{GREEK SMALL LETTER BETA}
"
self
.
fs
.
makedir
(
alpha
)
self
.
fs
.
makedir
(
alpha
)
self
.
fs
.
setcontents
(
alpha
+
"/a"
,
b
(
''
))
self
.
fs
.
setcontents
(
alpha
+
"/a"
,
b
(
''
))
self
.
fs
.
setcontents
(
alpha
+
"/"
+
beta
,
b
(
''
))
self
.
fs
.
setcontents
(
alpha
+
"/"
+
beta
,
b
(
''
))
self
.
assertTrue
(
self
.
check
(
alpha
))
self
.
assertTrue
(
self
.
check
(
alpha
))
self
.
assertEquals
(
sorted
(
self
.
fs
.
listdir
(
alpha
)),
[
"a"
,
beta
])
self
.
assertEquals
(
sorted
(
self
.
fs
.
listdir
(
alpha
)),
[
"a"
,
beta
])
...
...
fs/watch.py
View file @
41efb9b7
...
@@ -315,7 +315,7 @@ class WatchableFS(WatchableFSMixin,WrapFS):
...
@@ -315,7 +315,7 @@ class WatchableFS(WatchableFSMixin,WrapFS):
def
setcontents
(
self
,
path
,
data
=
b
''
,
encoding
=
None
,
errors
=
None
,
chunk_size
=
64
*
1024
):
def
setcontents
(
self
,
path
,
data
=
b
''
,
encoding
=
None
,
errors
=
None
,
chunk_size
=
64
*
1024
):
existed
=
self
.
wrapped_fs
.
isfile
(
path
)
existed
=
self
.
wrapped_fs
.
isfile
(
path
)
ret
=
super
(
WatchableFS
,
self
)
.
setcontents
(
path
,
data
,
chunk_size
=
chunk_size
)
ret
=
super
(
WatchableFS
,
self
)
.
setcontents
(
path
,
data
=
data
,
encoding
=
encoding
,
errors
=
errors
,
chunk_size
=
chunk_size
)
if
not
existed
:
if
not
existed
:
self
.
notify_watchers
(
CREATED
,
path
)
self
.
notify_watchers
(
CREATED
,
path
)
self
.
notify_watchers
(
ACCESSED
,
path
)
self
.
notify_watchers
(
ACCESSED
,
path
)
...
@@ -325,7 +325,7 @@ class WatchableFS(WatchableFSMixin,WrapFS):
...
@@ -325,7 +325,7 @@ class WatchableFS(WatchableFSMixin,WrapFS):
def
createfile
(
self
,
path
,
wipe
=
False
):
def
createfile
(
self
,
path
,
wipe
=
False
):
existed
=
self
.
wrapped_fs
.
isfile
(
path
)
existed
=
self
.
wrapped_fs
.
isfile
(
path
)
ret
=
super
(
WatchableFS
,
self
)
.
createfile
(
path
,
wipe
=
Fals
e
)
ret
=
super
(
WatchableFS
,
self
)
.
createfile
(
path
,
wipe
=
wip
e
)
if
not
existed
:
if
not
existed
:
self
.
notify_watchers
(
CREATED
,
path
)
self
.
notify_watchers
(
CREATED
,
path
)
self
.
notify_watchers
(
ACCESSED
,
path
)
self
.
notify_watchers
(
ACCESSED
,
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