Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Kulya
OpnSense
Commits
a2570701
Commit
a2570701
authored
Nov 25, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(proxy) some small performance improvements
parent
621d703a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
fetchACLs.py
src/opnsense/scripts/proxy/fetchACLs.py
+11
-9
No files found.
src/opnsense/scripts/proxy/fetchACLs.py
View file @
a2570701
...
...
@@ -137,11 +137,13 @@ class Downloader(object):
"""
self
.
fetch
()
for
filename
,
filehandle
in
self
.
get_files
():
basefilename
=
os
.
path
.
basename
(
filename
)
.
lower
()
file_ext
=
filename
.
split
(
'.'
)[
-
1
]
.
lower
()
while
True
:
line
=
filehandle
.
readline
()
if
not
line
:
break
yield
filename
,
line
yield
filename
,
basefilename
,
file_ext
,
line
class
DomainSorter
(
object
):
...
...
@@ -252,13 +254,14 @@ class DomainSorter(object):
prev_line
=
line
def
filename_in_ignorelist
(
filename
):
def
filename_in_ignorelist
(
bfilename
,
filename_ext
):
""" ignore certain files from processing.
:param filename: filename to inspect
:param bfilename: basefilename to inspect
:param filename_ext: extention of the filename
"""
if
filename
.
lower
()
.
split
(
'.'
)[
-
1
]
in
[
'pdf'
,
'txt'
,
'doc'
]:
if
filename
_ext
in
[
'pdf'
,
'txt'
,
'doc'
]:
return
True
elif
filename
.
lower
()
in
(
'readme'
,
'license'
,
'usage'
,
'categories'
):
elif
bfilename
in
(
'readme'
,
'license'
,
'usage'
,
'categories'
):
return
True
return
False
...
...
@@ -300,8 +303,8 @@ def main():
download_password
=
None
acl
=
Downloader
(
download_url
,
download_username
,
download_password
,
acl_max_timeout
)
all_filenames
=
list
()
for
filename
,
line
in
acl
.
download
():
if
filename_in_ignorelist
(
os
.
path
.
basename
(
filename
)
):
for
filename
,
basefilename
,
file_ext
,
line
in
acl
.
download
():
if
filename_in_ignorelist
(
basefilename
,
file_ext
):
# ignore documents, licenses and readme's
continue
...
...
@@ -325,8 +328,7 @@ def main():
continue
if
filetype
in
targets
and
targets
[
filetype
][
'handle'
]
is
None
:
targets
[
filetype
][
'handle'
]
=
targets
[
filetype
][
'class'
](
targets
[
filetype
][
'filename'
],
'wb'
)
targets
[
filetype
][
'handle'
]
=
targets
[
filetype
][
'class'
](
targets
[
filetype
][
'filename'
],
'wb'
)
if
filetype
in
targets
:
targets
[
filetype
][
'handle'
]
.
write
(
'
%
s
\n
'
%
line
)
# save index to disc
...
...
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