summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDaniel P. Berrange <berrange@redhat.com>2010-09-01 12:49:13 +0100
committerDaniel P. Berrange <berrange@redhat.com>2010-09-01 13:05:50 +0100
commit3f8715b9f4881847fcea192d06495d44c047348d (patch)
tree064be9b6eee2694831cd9bafe6944e32b82c9b1f /examples
parent785912f372be7b622fa613d24a5168f5c3170ed8 (diff)
downloadlibosinfo-3f8715b9f4881847fcea192d06495d44c047348d.tar.gz
Add two examples using GObject introspection
Add two example programs using GObject introspection bindings for Python (PyGObject) and Javascript (GJS) * examples/demo.js: Javascript demo * examples/demo.py: Python demo * Makefile.am, configure.ac: Add examples Makefile * examples/Makefile.am: Include demos in dist * libosinfo.spec.in: Include demo programs + docs * mingw32-libosinfo.spec.in: Kill docs
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile.am2
-rwxr-xr-xexamples/demo.js32
-rwxr-xr-xexamples/demo.py26
3 files changed, 60 insertions, 0 deletions
diff --git a/examples/Makefile.am b/examples/Makefile.am
new file mode 100644
index 0000000..02134e3
--- /dev/null
+++ b/examples/Makefile.am
@@ -0,0 +1,2 @@
+
+EXTRA_DIST = demo.js demo.py
diff --git a/examples/demo.js b/examples/demo.js
new file mode 100755
index 0000000..1113eba
--- /dev/null
+++ b/examples/demo.js
@@ -0,0 +1,32 @@
+#!/usr/bin/seed
+
+const osinfo = imports.gi.Libosinfo;
+
+var loader = new osinfo.Loader()
+loader.process_path("../data/libosinfo-dummy-data.xml")
+
+var db = loader.get_db()
+
+var devs = db.get_device_list()
+
+print (devs)
+
+for (idx in devs.get_elements()) {
+ var dev = devs.get_nth(idx)
+ print ("Device " + dev.get_id())
+}
+
+var names = db.unique_values_for_property_in_dev("name")
+
+for (idx in names) {
+ var name = names[idx]
+ print ("Name " + name)
+}
+
+var osnames = db.unique_values_for_property_in_os("short-id")
+
+for (idx in osnames) {
+ var name = osnames[idx]
+
+ print ("OS short id " + name)
+} \ No newline at end of file
diff --git a/examples/demo.py b/examples/demo.py
new file mode 100755
index 0000000..ac15ee3
--- /dev/null
+++ b/examples/demo.py
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+
+import gobject
+from gi.repository import Libosinfo as osinfo;
+
+loader = osinfo.Loader()
+loader.process_path("../data/libosinfo-dummy-data.xml")
+
+db = loader.get_db()
+
+devs = db.get_device_list()
+
+print devs
+
+for dev in devs.get_elements():
+ print ("Device " + dev.get_id())
+
+names = db.unique_values_for_property_in_dev("name")
+
+for name in names:
+ print ("Name " + name)
+
+osnames = db.unique_values_for_property_in_os("short-id")
+
+for name in osnames:
+ print ("OS short id " + name)