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
7f9532d0
Commit
7f9532d0
authored
Jan 05, 2011
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow listdir/ilistdir to take non-keyword args
parent
cb43070a
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
46 additions
and
14 deletions
+46
-14
fs/__init__.py
+1
-1
fs/base.py
+6
-1
fs/httpfs.py
+0
-0
fs/remote.py
+4
-4
fs/tests/test_wrapfs.py
+3
-0
fs/wrapfs/__init__.py
+12
-2
fs/wrapfs/hidedotfilesfs.py
+16
-2
fs/xattrs.py
+4
-4
No files found.
fs/__init__.py
View file @
7f9532d0
...
@@ -15,7 +15,7 @@ implementations of this interface such as:
...
@@ -15,7 +15,7 @@ implementations of this interface such as:
"""
"""
__version__
=
"0.4.0a
7
"
__version__
=
"0.4.0a
8
"
__author__
=
"Will McGugan (will@willmcgugan.com)"
__author__
=
"Will McGugan (will@willmcgugan.com)"
# 'base' imports * from 'path' and 'errors', so their
# 'base' imports * from 'path' and 'errors', so their
...
...
fs/base.py
View file @
7f9532d0
...
@@ -491,7 +491,12 @@ class FS(object):
...
@@ -491,7 +491,12 @@ class FS(object):
instead of a list. Depending on the filesystem this may be more
instead of a list. Depending on the filesystem this may be more
efficient than calling listdir() and iterating over the resulting list.
efficient than calling listdir() and iterating over the resulting list.
"""
"""
return
iter
(
self
.
listdir
(
path
,
wildcard
,
full
,
absolute
,
dirs_only
,
files_only
))
return
iter
(
self
.
listdir
(
path
,
wildcard
=
wildcard
,
full
=
full
,
absolute
=
absolute
,
dirs_only
=
dirs_only
,
files_only
=
files_only
))
def
ilistdirinfo
(
self
,
path
=
"./"
,
def
ilistdirinfo
(
self
,
path
=
"./"
,
wildcard
=
None
,
wildcard
=
None
,
...
...
fs/httpfs.py
View file @
7f9532d0
fs/remote.py
View file @
7f9532d0
...
@@ -493,12 +493,12 @@ class CacheFS(WrapFS):
...
@@ -493,12 +493,12 @@ class CacheFS(WrapFS):
return
super
(
CacheFS
,
self
)
.
isfile
(
path
)
return
super
(
CacheFS
,
self
)
.
isfile
(
path
)
@_cached_method
@_cached_method
def
listdir
(
self
,
path
=
""
,
**
kwds
):
def
listdir
(
self
,
path
=
""
,
*
args
,
*
*
kwds
):
return
super
(
CacheFS
,
self
)
.
listdir
(
path
,
**
kwds
)
return
super
(
CacheFS
,
self
)
.
listdir
(
path
,
*
args
,
*
*
kwds
)
@_cached_method
@_cached_method
def
listdirinfo
(
self
,
path
=
""
,
**
kwds
):
def
listdirinfo
(
self
,
path
=
""
,
*
args
,
*
*
kwds
):
return
super
(
CacheFS
,
self
)
.
listdirinfo
(
path
,
**
kwds
)
return
super
(
CacheFS
,
self
)
.
listdirinfo
(
path
,
*
args
,
*
*
kwds
)
@_cached_method
@_cached_method
def
getinfo
(
self
,
path
):
def
getinfo
(
self
,
path
):
...
...
fs/tests/test_wrapfs.py
View file @
7f9532d0
...
@@ -93,11 +93,14 @@ class TestHideDotFilesFS(unittest.TestCase):
...
@@ -93,11 +93,14 @@ class TestHideDotFilesFS(unittest.TestCase):
def
test_hidden
(
self
):
def
test_hidden
(
self
):
self
.
assertEquals
(
len
(
self
.
fs
.
listdir
(
hidden
=
False
)),
2
)
self
.
assertEquals
(
len
(
self
.
fs
.
listdir
(
hidden
=
False
)),
2
)
self
.
assertEquals
(
len
(
list
(
self
.
fs
.
ilistdir
(
hidden
=
False
))),
2
)
def
test_nonhidden
(
self
):
def
test_nonhidden
(
self
):
self
.
assertEquals
(
len
(
self
.
fs
.
listdir
(
hidden
=
True
)),
4
)
self
.
assertEquals
(
len
(
self
.
fs
.
listdir
(
hidden
=
True
)),
4
)
self
.
assertEquals
(
len
(
list
(
self
.
fs
.
ilistdir
(
hidden
=
True
))),
4
)
def
test_default
(
self
):
def
test_default
(
self
):
self
.
assertEquals
(
len
(
self
.
fs
.
listdir
()),
2
)
self
.
assertEquals
(
len
(
self
.
fs
.
listdir
()),
2
)
self
.
assertEquals
(
len
(
list
(
self
.
fs
.
ilistdir
())),
2
)
fs/wrapfs/__init__.py
View file @
7f9532d0
...
@@ -224,7 +224,12 @@ class WrapFS(FS):
...
@@ -224,7 +224,12 @@ class WrapFS(FS):
yield
e
yield
e
@rewrite_errors
@rewrite_errors
def
listdirinfo
(
self
,
path
=
""
,
**
kwds
):
def
listdirinfo
(
self
,
path
=
""
,
wildcard
=
None
,
full
=
False
,
absolute
=
False
,
dirs_only
=
False
,
files_only
=
False
):
kwds
=
dict
(
wildcard
=
wildcard
,
full
=
full
,
absolute
=
absolute
,
dirs_only
=
dirs_only
,
files_only
=
files_only
)
full
=
kwds
.
pop
(
"full"
,
False
)
full
=
kwds
.
pop
(
"full"
,
False
)
absolute
=
kwds
.
pop
(
"absolute"
,
False
)
absolute
=
kwds
.
pop
(
"absolute"
,
False
)
wildcard
=
kwds
.
pop
(
"wildcard"
,
None
)
wildcard
=
kwds
.
pop
(
"wildcard"
,
None
)
...
@@ -247,7 +252,12 @@ class WrapFS(FS):
...
@@ -247,7 +252,12 @@ class WrapFS(FS):
return
entries
return
entries
@rewrite_errors
@rewrite_errors
def
ilistdirinfo
(
self
,
path
=
""
,
**
kwds
):
def
ilistdirinfo
(
self
,
path
=
""
,
wildcard
=
None
,
full
=
False
,
absolute
=
False
,
dirs_only
=
False
,
files_only
=
False
):
kwds
=
dict
(
wildcard
=
wildcard
,
full
=
full
,
absolute
=
absolute
,
dirs_only
=
dirs_only
,
files_only
=
files_only
)
full
=
kwds
.
pop
(
"full"
,
False
)
full
=
kwds
.
pop
(
"full"
,
False
)
absolute
=
kwds
.
pop
(
"absolute"
,
False
)
absolute
=
kwds
.
pop
(
"absolute"
,
False
)
wildcard
=
kwds
.
pop
(
"wildcard"
,
None
)
wildcard
=
kwds
.
pop
(
"wildcard"
,
None
)
...
...
fs/wrapfs/hidedotfilesfs.py
View file @
7f9532d0
...
@@ -28,13 +28,27 @@ class HideDotFilesFS(WrapFS):
...
@@ -28,13 +28,27 @@ class HideDotFilesFS(WrapFS):
def
_decode
(
self
,
path
):
def
_decode
(
self
,
path
):
return
path
return
path
def
listdir
(
self
,
path
=
""
,
**
kwds
):
def
listdir
(
self
,
path
=
""
,
wildcard
=
None
,
full
=
False
,
absolute
=
False
,
dirs_only
=
False
,
files_only
=
False
,
hidden
=
False
):
hidden
=
kwds
.
pop
(
"hidden"
,
False
)
kwds
=
dict
(
wildcard
=
wildcard
,
full
=
full
,
absolute
=
absolute
,
dirs_only
=
dirs_only
,
files_only
=
files_only
)
entries
=
self
.
wrapped_fs
.
listdir
(
path
,
**
kwds
)
entries
=
self
.
wrapped_fs
.
listdir
(
path
,
**
kwds
)
if
not
hidden
:
if
not
hidden
:
entries
=
[
e
for
e
in
entries
if
not
self
.
is_hidden
(
e
)]
entries
=
[
e
for
e
in
entries
if
not
self
.
is_hidden
(
e
)]
return
entries
return
entries
def
ilistdir
(
self
,
path
=
""
,
wildcard
=
None
,
full
=
False
,
absolute
=
False
,
dirs_only
=
False
,
files_only
=
False
,
hidden
=
False
):
kwds
=
dict
(
wildcard
=
wildcard
,
full
=
full
,
absolute
=
absolute
,
dirs_only
=
dirs_only
,
files_only
=
files_only
)
for
e
in
self
.
wrapped_fs
.
ilistdir
(
path
,
**
kwds
):
if
hidden
or
not
self
.
is_hidden
(
e
):
yield
e
def
walk
(
self
,
path
=
"/"
,
wildcard
=
None
,
dir_wildcard
=
None
,
search
=
"breadth"
,
hidden
=
False
):
def
walk
(
self
,
path
=
"/"
,
wildcard
=
None
,
dir_wildcard
=
None
,
search
=
"breadth"
,
hidden
=
False
):
if
search
==
"breadth"
:
if
search
==
"breadth"
:
dirs
=
[
path
]
dirs
=
[
path
]
...
...
fs/xattrs.py
View file @
7f9532d0
...
@@ -144,14 +144,14 @@ class SimulateXAttr(WrapFS):
...
@@ -144,14 +144,14 @@ class SimulateXAttr(WrapFS):
def
_decode
(
self
,
path
):
def
_decode
(
self
,
path
):
return
path
return
path
def
listdir
(
self
,
path
=
""
,
**
kwds
):
def
listdir
(
self
,
path
=
""
,
*
args
,
*
*
kwds
):
"""Prevent .xattr from appearing in listings."""
"""Prevent .xattr from appearing in listings."""
entries
=
self
.
wrapped_fs
.
listdir
(
path
,
**
kwds
)
entries
=
self
.
wrapped_fs
.
listdir
(
path
,
*
args
,
*
*
kwds
)
return
[
e
for
e
in
entries
if
not
self
.
_is_attr_path
(
e
)]
return
[
e
for
e
in
entries
if
not
self
.
_is_attr_path
(
e
)]
def
ilistdir
(
self
,
path
=
""
,
**
kwds
):
def
ilistdir
(
self
,
path
=
""
,
*
args
,
*
*
kwds
):
"""Prevent .xattr from appearing in listings."""
"""Prevent .xattr from appearing in listings."""
for
e
in
self
.
wrapped_fs
.
ilistdir
(
path
,
**
kwds
):
for
e
in
self
.
wrapped_fs
.
ilistdir
(
path
,
*
args
,
*
*
kwds
):
if
not
self
.
_is_attr_path
(
e
):
if
not
self
.
_is_attr_path
(
e
):
yield
e
yield
e
...
...
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