Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
%.pc: %.pc.in Makefile
$(SED_PROCESS)
+EXTRA_DIST += \
+ examples/python/create-database.py \
+ examples/python/read-database.py
+
pkginclude_HEADERS = \
src/loc/libloc.h \
src/loc/as.h \
--- /dev/null
+#!/usr/bin/python3
+
+import location
+
+w = location.Writer()
+
+# Set the vendor
+w.vendor = "IPFire Project"
+
+# Set a description
+w.description = "This is a geo location database"
+
+# Add an AS
+a = w.add_as(204867)
+a.name = "Lightning Wire Labs GmbH"
+
+print(a)
+
+# Add a network
+n = w.add_network("2a07:1c44:5800::/40")
+n.country_code = "DE"
+n.asn = a.number
+
+print(n)
+
+# Write the database to disk
+w.write("test.db")
--- /dev/null
+#!/usr/bin/python3
+
+import location
+
+# Open the database
+d = location.Database("test.db")
+print(d)
+
+# Try to get information about AS123
+a = d.get_as(123)
+print(a)
+
+# Try to get information about AS204867
+a = d.get_as(204867)
+print(a)
+
+# Search for an IP address in the database
+n = d.lookup("8.8.8.8")
+print(n)