Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libloc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
libloc
Commits
7c922e9c
Commit
7c922e9c
authored
Oct 15, 2019
by
Michael Tremer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
python: Implement lookup function for countries
Signed-off-by:
Michael Tremer
<
michael.tremer@ipfire.org
>
parent
af208e26
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
src/python/database.c
src/python/database.c
+25
-0
No files found.
src/python/database.c
View file @
7c922e9c
...
...
@@ -21,6 +21,7 @@
#include "locationmodule.h"
#include "as.h"
#include "country.h"
#include "database.h"
#include "network.h"
...
...
@@ -120,6 +121,24 @@ static PyObject* Database_get_as(DatabaseObject* self, PyObject* args) {
return
NULL
;
}
static
PyObject
*
Database_get_country
(
DatabaseObject
*
self
,
PyObject
*
args
)
{
const
char
*
country_code
=
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"s"
,
&
country_code
))
return
NULL
;
struct
loc_country
*
country
;
int
r
=
loc_database_get_country
(
self
->
db
,
&
country
,
country_code
);
if
(
r
)
{
Py_RETURN_NONE
;
}
PyObject
*
obj
=
new_country
(
&
CountryType
,
country
);
loc_country_unref
(
country
);
return
obj
;
}
static
PyObject
*
Database_lookup
(
DatabaseObject
*
self
,
PyObject
*
args
)
{
struct
loc_network
*
network
=
NULL
;
const
char
*
address
=
NULL
;
...
...
@@ -231,6 +250,12 @@ static struct PyMethodDef Database_methods[] = {
METH_VARARGS
,
NULL
,
},
{
"get_country"
,
(
PyCFunction
)
Database_get_country
,
METH_VARARGS
,
NULL
,
},
{
"lookup"
,
(
PyCFunction
)
Database_lookup
,
...
...
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