Skip to content

Commit b476ec5

Browse files
author
tjmather
committed
Export the country list, country code -> country name mapping, and country->continent mapping
1 parent ef814c3 commit b476ec5

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
* Export the country list, country code -> country name mapping, and country->continent
2+
mapping ( Ignacio Vazquez-Abrams )
13
* Changed license to LGPL from GPL
24

35
1.2.1 2005-06-28

py_GeoIP.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,28 @@ initGeoIP(void)
306306
m = Py_InitModule("GeoIP", GeoIP_Class_methods);
307307
d = PyModule_GetDict(m);
308308

309+
int total_ccodes = 251;
310+
311+
PyObject *ccode = PyTuple_New(total_ccodes);
312+
PyObject *cname = PyDict_New();
313+
PyObject *ccont = PyDict_New();
314+
PyObject *s;
315+
316+
int i = 0;
317+
for (; i<total_ccodes; i++)
318+
{
319+
s = PyString_FromString(GeoIP_country_code[i]);
320+
PyTuple_SET_ITEM(ccode, i, s);
321+
Py_INCREF(s);
322+
PyDict_SetItem(cname, s, PyString_FromString(GeoIP_country_name[i]));
323+
Py_INCREF(s);
324+
PyDict_SetItem(ccont, s, PyString_FromString(GeoIP_country_continent[i]));
325+
};
326+
327+
PyDict_SetItemString(d, "country_codes", ccode);
328+
PyDict_SetItemString(d, "country_names", cname);
329+
PyDict_SetItemString(d, "country_continents", ccont);
330+
309331
tmp = PyInt_FromLong(0);
310332
PyDict_SetItemString(d, "GEOIP_STANDARD", tmp);
311333
Py_DECREF(tmp);

0 commit comments

Comments
 (0)