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
dccbc1f3
Commit
dccbc1f3
authored
Jun 15, 2012
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for hide fs
parent
1086125b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
8 deletions
+14
-8
fs/base.py
+0
-3
fs/watch.py
+1
-0
fs/wrapfs/hidefs.py
+13
-5
No files found.
fs/base.py
View file @
dccbc1f3
...
...
@@ -170,9 +170,6 @@ class FS(object):
else
:
self
.
_lock
=
DummyLock
()
def
__repr__
(
self
):
return
self
.
__str__
()
def
__del__
(
self
):
if
not
getattr
(
self
,
'closed'
,
True
):
try
:
...
...
fs/watch.py
View file @
dccbc1f3
...
...
@@ -45,6 +45,7 @@ from fs.filelike import FileWrapper
class
EVENT
(
object
):
"""Base class for change notification events."""
def
__init__
(
self
,
fs
,
path
):
super
(
EVENT
,
self
)
.
__init__
()
self
.
fs
=
fs
if
path
is
not
None
:
path
=
abspath
(
normpath
(
path
))
...
...
fs/wrapfs/hidefs.py
View file @
dccbc1f3
...
...
@@ -7,7 +7,8 @@ Removes resources from a directory listing if they match a given set of wildcard
"""
from
fs.wrapfs
import
WrapFS
from
fs.path
import
basename
from
fs.path
import
iteratepath
from
fs.errors
import
ResourceNotFoundError
import
re
import
fnmatch
...
...
@@ -16,7 +17,7 @@ class HideFS(WrapFS):
For example, to hide all pyc file and subversion directories from a filesystem::
HideFS(my_fs, "*.pyc", ".svn")
hide_fs =
HideFS(my_fs, "*.pyc", ".svn")
"""
...
...
@@ -24,16 +25,23 @@ class HideFS(WrapFS):
self
.
_hide_wildcards
=
[
re
.
compile
(
fnmatch
.
translate
(
wildcard
))
for
wildcard
in
hide_wildcards
]
super
(
HideFS
,
self
)
.
__init__
(
wrapped_fs
)
def
_should_hide
(
self
,
name
):
name
=
basename
(
name
)
return
any
(
wildcard
.
match
(
name
)
for
wildcard
in
self
.
_hide_wildcards
)
def
_should_hide
(
self
,
path
):
return
any
(
any
(
wildcard
.
match
(
part
)
for
wildcard
in
self
.
_hide_wildcards
)
for
part
in
iteratepath
(
path
)
)
def
_encode
(
self
,
path
):
if
self
.
_should_hide
(
path
):
raise
ResourceNotFoundError
(
path
)
return
path
def
_decode
(
self
,
path
):
return
path
def
exists
(
self
,
path
):
if
self
.
_should_hide
(
path
):
return
False
return
super
(
HideFS
,
self
)
.
exists
(
path
)
def
listdir
(
self
,
path
=
""
,
*
args
,
**
kwargs
):
entries
=
super
(
HideFS
,
self
)
.
listdir
(
path
,
*
args
,
**
kwargs
)
entries
=
[
entry
for
entry
in
entries
if
not
self
.
_should_hide
(
entry
)]
...
...
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