-
-
Notifications
You must be signed in to change notification settings - Fork 128
Expand file tree
/
Copy pathgenerate_mmdb.py
More file actions
63 lines (56 loc) · 1.35 KB
/
generate_mmdb.py
File metadata and controls
63 lines (56 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from netaddr import IPSet
from mmdb_writer import MMDBWriter
city_writer = MMDBWriter()
city_writer.insert_network(
IPSet(["44.55.66.77/32"]),
{
"city": {
"names": {
"en": "San Diego",
},
},
"continent": {
"code": "NA",
"names": {
"en": "North America",
},
},
"country": {
"iso_code": "US",
"names": {
"en": "United States",
},
},
"is_in_european_union": False,
"location": {
"latitude": 37.751,
"longitude": -97.822,
"metro_code": "custom metro code",
"time_zone": "America/Los Angeles",
},
"postal": {
"code": "custom postal code",
},
"subdivisions": [
{
"iso_code": "ABC",
"names": {
"en": 'Absolute Basic Class',
},
},
],
},
)
city_writer.to_db_file("tests/test_city.mmdb")
# country_writer = MMDBWriter(
# IPSet(["8.8.8.8/32"]),
# {
# "country": {
# "iso_code": "US",
# "names": {
# "en": "United States",
# },
# },
# },
# )
# country_writer.to_db_file("tests/test_country.mmdb")