Skip to content

Commit 37b9a44

Browse files
committed
Add missing docs
1 parent 06b1b62 commit 37b9a44

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

geoip2/database.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
import geoip2.errors
1212
import maxminddb
1313

14+
# pylint: disable=unused-import
1415
from maxminddb import (MODE_AUTO, MODE_MMAP, MODE_MMAP_EXT, MODE_FILE,
1516
MODE_MEMORY)
1617

1718

1819
class Reader(object):
1920

20-
"""Creates a new GeoIP2 database Reader object.
21+
"""GeoIP2 database Reader object.
2122
2223
Instances of this class provide a reader for the GeoIP2 database format.
2324
IP addresses can be looked up using the ``country`` and ``city`` methods.
@@ -44,6 +45,41 @@ class Reader(object):
4445
"""
4546

4647
def __init__(self, filename, locales=None, mode=MODE_AUTO):
48+
"""Create GeoIP2 Reader
49+
50+
:param filename: The path to the GeoIP2 database.
51+
:param locales: This is list of locale codes. This argument will be
52+
passed on to record classes to use when their name properties are
53+
called. The default value is ['en'].
54+
55+
The order of the locales is significant. When a record class has
56+
multiple names (country, city, etc.), its name property will return
57+
the name in the first locale that has one.
58+
59+
Note that the only locale which is always present in the GeoIP2
60+
data is "en". If you do not include this locale, the name property
61+
may end up returning None even when the record has an English name.
62+
63+
Currently, the valid locale codes are:
64+
65+
* de -- German
66+
* en -- English names may still include accented characters if that is
67+
the accepted spelling in English. In other words, English does not
68+
mean ASCII.
69+
* es -- Spanish
70+
* fr -- French
71+
* ja -- Japanese
72+
* pt-BR -- Brazilian Portuguese
73+
* ru -- Russian
74+
* zh-CN -- Simplified Chinese.
75+
:param mode: The mode to open the database with. Valid mode are:
76+
* MODE_MMAP_EXT - use the C extension with memory map.
77+
* MODE_MMAP - read from memory map. Pure Python.
78+
* MODE_FILE - read database as standard file. Pure Python.
79+
* MODE_MEMORY - load database into memory. Pure Python.
80+
* MODE_AUTO - try MODE_MMAP_EXT, MODE_MMAP, MODE_FILE in that order. Default.
81+
82+
"""
4783
if locales is None:
4884
locales = ['en']
4985
self._db_reader = maxminddb.open_database(filename, mode)

0 commit comments

Comments
 (0)