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
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
24 deletions
+23
-24
LICENSE.txt
+4
-4
fs/__init__.py
+1
-1
fs/errors.py
+4
-0
fs/expose/fuse/fuse3.py
+0
-0
fs/osfs/__init__.py
+10
-14
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,
are permitted provided that the following conditions are met:
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
documentation and/or other materials provided with the distribution.
...
...
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
This diff is collapsed.
Click to expand it.
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,22 +286,15 @@ class OSFS(OSFSXAttrMixin, OSFSWatchMixin, FS):
...
@@ -283,22 +286,15 @@ 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
)
os
.
rmdir
(
sys_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
)
# 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.
if
recursive
:
if
recursive
:
...
...
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