Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pygeoip
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
pygeoip
Commits
f4fdc5a6
Commit
f4fdc5a6
authored
Jul 22, 2013
by
William Tisäter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make tests pass on Python 3.X
parent
671d3ab9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
8 deletions
+3
-8
pygeoip/__init__.py
+3
-5
tests/test.py
+0
-3
No files found.
pygeoip/__init__.py
View file @
f4fdc5a6
...
...
@@ -62,9 +62,6 @@ class _GeoIPMetaclass(type):
def
__call__
(
cls
,
*
args
,
**
kwargs
):
""" Singleton method to gets an instance without reparsing
the database, the filename is being used as cache key.
@param cache: Used in tests for skipping instance caching
@type cache: bool
"""
if
len
(
args
)
>
0
:
filename
=
args
[
0
]
...
...
@@ -74,7 +71,6 @@ class _GeoIPMetaclass(type):
return
None
if
not
kwargs
.
get
(
'cache'
,
True
):
del
kwargs
[
'cache'
]
return
super
(
_GeoIPMetaclass
,
cls
)
.
__call__
(
*
args
,
**
kwargs
)
cls
.
_instance_lock
.
acquire
()
...
...
@@ -88,7 +84,7 @@ class _GeoIPMetaclass(type):
class
GeoIP
(
object
):
__metaclass__
=
_GeoIPMetaclass
def
__init__
(
self
,
filename
,
flags
=
0
):
def
__init__
(
self
,
filename
,
flags
=
0
,
cache
=
True
):
"""
Initialize the class.
...
...
@@ -99,6 +95,8 @@ class GeoIP(object):
MEMORY_CACHE (preload the whole file into memory) and
MMAP_CACHE (access the file via mmap).
@type flags: int
@param cache: Used in tests to skip instance caching
@type cache: bool
"""
self
.
_flags
=
flags
...
...
tests/test.py
View file @
f4fdc5a6
...
...
@@ -9,9 +9,6 @@ from tests.config import COUNTRY_DB_PATH
class
TestGenerals
(
unittest
.
TestCase
):
def
testContructing
(
self
):
gi
=
pygeoip
.
GeoIP
()
self
.
assertEqual
(
gi
,
None
)
gi
=
pygeoip
.
GeoIP
(
filename
=
COUNTRY_DB_PATH
)
self
.
assertEqual
(
gi
.
_type
,
'STANDARD'
)
...
...
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