Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mentat-test
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
713
Mentat
mentat-test
Commits
a5d79997
Commit
a5d79997
authored
7 years ago
by
Jan Mach
Browse files
Options
Downloads
Patches
Plain Diff
Code style improvements with pylint tool.
Fixed all pylint issues in mentat.geoip module. (Redmine issue:
#3443
)
parent
4725772f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.pylintrc-lib
+1
-1
1 addition, 1 deletion
.pylintrc-lib
lib/mentat/geoip.py
+14
-8
14 additions, 8 deletions
lib/mentat/geoip.py
with
15 additions
and
9 deletions
.pylintrc-lib
+
1
−
1
View file @
a5d79997
...
...
@@ -297,7 +297,7 @@ ignored-classes=optparse.Values,thread._local,_thread._local
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=rrdtool
ignored-modules=rrdtool
,geoip2.records
# Show a hint with possible names when a member name was not found. The aspect
# of finding the hint is based on edit distance.
...
...
This diff is collapsed.
Click to expand it.
lib/mentat/geoip.py
+
14
−
8
View file @
a5d79997
...
...
@@ -51,15 +51,19 @@ class GeoipService:
"""
def
__init__
(
self
,
asndb
=
None
,
citydb
=
None
,
countrydb
=
None
):
"""
Initialize geolocation service with paths to desired database files.
"""
self
.
fn_asndb
=
asndb
self
.
fn_citydb
=
citydb
self
.
fn_countrydb
=
countrydb
self
.
asndb
=
None
self
.
citydb
=
None
self
.
countrydb
=
None
def
__del__
(
self
):
"""
Close internal geolocation database readers.
"""
if
self
.
fn_asndb
:
self
.
asndb
.
close
()
...
...
@@ -70,16 +74,18 @@ class GeoipService:
def
setup
(
self
):
"""
Setup internal geolocation database readers.
"""
if
self
.
fn_asndb
:
self
.
asndb
=
geoip2
.
database
.
Reader
(
self
.
fn_asndb
)
else
:
self
.
asndb
=
None
if
self
.
fn_citydb
:
self
.
citydb
=
geoip2
.
database
.
Reader
(
self
.
fn_citydb
)
else
:
self
.
citydb
=
None
if
self
.
fn_countrydb
:
self
.
countrydb
=
geoip2
.
database
.
Reader
(
self
.
fn_countrydb
)
else
:
...
...
@@ -87,7 +93,7 @@ class GeoipService:
def
status
(
self
):
"""
Display status of internal geolocation readers.
"""
return
{
'
asn
'
:
self
.
fn_asndb
,
...
...
@@ -97,7 +103,7 @@ class GeoipService:
def
lookup
(
self
,
ipaddr
):
"""
Lookup given IP address in all databases.
"""
result
=
{}
if
self
.
fn_asndb
:
...
...
@@ -110,7 +116,7 @@ class GeoipService:
def
lookup_asn
(
self
,
ipaddr
):
"""
Lookup given IP address in ASN database.
"""
try
:
...
...
@@ -126,7 +132,7 @@ class GeoipService:
def
lookup_city
(
self
,
ipaddr
):
"""
Lookup given IP address in city database.
"""
try
:
...
...
@@ -148,7 +154,7 @@ class GeoipService:
def
lookup_country
(
self
,
ipaddr
):
"""
Lookup given IP address in Country database.
"""
try
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment