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
07888d97
Commit
07888d97
authored
Jul 03, 2012
by
willmcgugan@gmail.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Applied patch to sftp that searches for ssh keys in default locations
parent
dccbc1f3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
14 deletions
+14
-14
fs/sftpfs.py
+0
-0
fs/utils.py
+0
-0
fs/wrapfs/hidefs.py
+14
-14
No files found.
fs/sftpfs.py
View file @
07888d97
This diff is collapsed.
Click to expand it.
fs/utils.py
View file @
07888d97
This diff is collapsed.
Click to expand it.
fs/wrapfs/hidefs.py
View file @
07888d97
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
fs.wrapfs.hidefs
fs.wrapfs.hidefs
================
================
Removes resources from a directory listing if they match a given set of wildcards
Removes resources from a directory listing if they match a given set of wildcards
"""
"""
...
@@ -12,23 +12,24 @@ from fs.errors import ResourceNotFoundError
...
@@ -12,23 +12,24 @@ from fs.errors import ResourceNotFoundError
import
re
import
re
import
fnmatch
import
fnmatch
class
HideFS
(
WrapFS
):
class
HideFS
(
WrapFS
):
"""FS wrapper that hides resources if they match a wildcard(s).
"""FS wrapper that hides resources if they match a wildcard(s).
For example, to hide all pyc file and subversion directories from a filesystem::
For example, to hide all pyc file and subversion directories from a filesystem::
hide_fs = HideFS(my_fs, "*.pyc", ".svn")
hide_fs = HideFS(my_fs, "*.pyc", ".svn")
"""
"""
def
__init__
(
self
,
wrapped_fs
,
*
hide_wildcards
):
def
__init__
(
self
,
wrapped_fs
,
*
hide_wildcards
):
self
.
_hide_wildcards
=
[
re
.
compile
(
fnmatch
.
translate
(
wildcard
))
for
wildcard
in
hide_wildcards
]
self
.
_hide_wildcards
=
[
re
.
compile
(
fnmatch
.
translate
(
wildcard
))
for
wildcard
in
hide_wildcards
]
super
(
HideFS
,
self
)
.
__init__
(
wrapped_fs
)
super
(
HideFS
,
self
)
.
__init__
(
wrapped_fs
)
def
_should_hide
(
self
,
path
):
def
_should_hide
(
self
,
path
):
return
any
(
any
(
wildcard
.
match
(
part
)
for
wildcard
in
self
.
_hide_wildcards
)
return
any
(
any
(
wildcard
.
match
(
part
)
for
wildcard
in
self
.
_hide_wildcards
)
for
part
in
iteratepath
(
path
))
for
part
in
iteratepath
(
path
))
def
_encode
(
self
,
path
):
def
_encode
(
self
,
path
):
if
self
.
_should_hide
(
path
):
if
self
.
_should_hide
(
path
):
raise
ResourceNotFoundError
(
path
)
raise
ResourceNotFoundError
(
path
)
...
@@ -42,12 +43,12 @@ class HideFS(WrapFS):
...
@@ -42,12 +43,12 @@ class HideFS(WrapFS):
return
False
return
False
return
super
(
HideFS
,
self
)
.
exists
(
path
)
return
super
(
HideFS
,
self
)
.
exists
(
path
)
def
listdir
(
self
,
path
=
""
,
*
args
,
**
kwargs
):
def
listdir
(
self
,
path
=
""
,
*
args
,
**
kwargs
):
entries
=
super
(
HideFS
,
self
)
.
listdir
(
path
,
*
args
,
**
kwargs
)
entries
=
super
(
HideFS
,
self
)
.
listdir
(
path
,
*
args
,
**
kwargs
)
entries
=
[
entry
for
entry
in
entries
if
not
self
.
_should_hide
(
entry
)]
entries
=
[
entry
for
entry
in
entries
if
not
self
.
_should_hide
(
entry
)]
return
entries
return
entries
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
from
fs.osfs
import
OSFS
from
fs.osfs
import
OSFS
hfs
=
HideFS
(
OSFS
(
'~/projects/pyfilesystem'
),
"*.pyc"
,
".svn"
)
hfs
=
HideFS
(
OSFS
(
'~/projects/pyfilesystem'
),
"*.pyc"
,
".svn"
)
hfs
.
tree
()
hfs
.
tree
()
\ No newline at end of file
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