Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
slapos.toolbox
Commits
7c327f1a
Commit
7c327f1a
authored
May 25, 2015
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slaprunner: filter out some usless file extensions in tree view
parent
17daad5a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
slapos/runner/fileBrowser.py
slapos/runner/fileBrowser.py
+17
-2
No files found.
slapos/runner/fileBrowser.py
View file @
7c327f1a
...
...
@@ -9,6 +9,7 @@ import re
import
shutil
import
urllib
import
zipfile
import
fnmatch
import
werkzeug
from
slapos.runner.utils
import
realpath
,
tail
,
isText
...
...
@@ -26,6 +27,20 @@ class FileBrowser(object):
raise
NameError
(
'Could not load directory %s: Permission denied'
%
dir
)
return
realdir
def
_filterPathList
(
self
,
path_list
):
"""Filter out paths that matches a list ignored file patterns.
"""
# This could be configurable ...
ignored_file_list
=
'''
*.py[cod]
*.o
'''
for
pattern
in
ignored_file_list
.
splitlines
():
if
pattern
.
strip
():
path_list
=
[
path
for
path
in
path_list
if
not
fnmatch
.
fnmatch
(
path
,
pattern
)]
return
path_list
def
listDirs
(
self
,
dir
,
all
=
False
):
"""List elements of directory 'dir' taken"""
html
=
'var gsdirs = [], gsfiles = [];'
...
...
@@ -37,7 +52,7 @@ class FileBrowser(object):
raise
NameError
(
'Could not load directory %s: Permission denied'
%
dir
)
ldir
=
sorted
(
os
.
listdir
(
realdir
),
key
=
str
.
lower
)
for
f
in
ldir
:
for
f
in
self
.
_filterPathList
(
ldir
)
:
if
f
.
startswith
(
'.'
)
and
not
all
:
# do not display this file/folder
continue
ff
=
os
.
path
.
join
(
dir
,
f
)
...
...
@@ -67,7 +82,7 @@ class FileBrowser(object):
dirList = []
i = 0
ldir = sorted(os.listdir(realdir), key=str.lower)
for f in
ldir
:
for f in
self._filterPathList(ldir)
:
if f.startswith('.') and not all: # do not display this file/folder
continue
ff = os.path.join(dir, f)
...
...
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