From fbb61baf515b78b6f8246335fb2d9b077a29ee1d Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Sun, 22 Nov 2020 21:48:02 +0100 Subject: examples: Rename `introspection/python` -> `python` --- examples/introspection/python/all-async.py | 30 ------------------- examples/introspection/python/miner.py | 43 ---------------------------- examples/introspection/python/query-async.py | 25 ---------------- examples/introspection/python/query-sync.py | 9 ------ examples/python/all-async.py | 30 +++++++++++++++++++ examples/python/miner.py | 43 ++++++++++++++++++++++++++++ examples/python/query-async.py | 25 ++++++++++++++++ examples/python/query-sync.py | 9 ++++++ 8 files changed, 107 insertions(+), 107 deletions(-) delete mode 100755 examples/introspection/python/all-async.py delete mode 100755 examples/introspection/python/miner.py delete mode 100755 examples/introspection/python/query-async.py delete mode 100755 examples/introspection/python/query-sync.py create mode 100755 examples/python/all-async.py create mode 100755 examples/python/miner.py create mode 100755 examples/python/query-async.py create mode 100755 examples/python/query-sync.py (limited to 'examples') diff --git a/examples/introspection/python/all-async.py b/examples/introspection/python/all-async.py deleted file mode 100755 index 70a3b2b1f..000000000 --- a/examples/introspection/python/all-async.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python -import gi -from gi.repository import Tracker, GObject - - -def results_ready_cb (obj, result, user_data): - cursor = obj.query_finish (result) - - # This can also be done asynchronously - while (cursor.next (None)): - print cursor.get_string (0) - - user_data.quit () - -def connection_ready_cb (object, result, user_data): - assert user_data - conn = Tracker.SparqlConnection.get_finish (result) - - conn.query_async ("SELECT ?u WHERE { ?u a nie:InformationElement. }", - None, - results_ready_cb, - user_data) - - -if __name__ == "__main__": - loop = GObject.MainLoop () - - Tracker.SparqlConnection.get_async (None, connection_ready_cb, loop) - - loop.run () diff --git a/examples/introspection/python/miner.py b/examples/introspection/python/miner.py deleted file mode 100755 index 8bc39d574..000000000 --- a/examples/introspection/python/miner.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python -import gi -from gi.repository import TrackerMiner, GLib, GObject, Gio - - -class MyMiner (TrackerMiner.Miner): - __gtype_name__ = 'MyMiner' - - def __init__ (self): - TrackerMiner.Miner.__init__ (self, - name="MyMiner", - progress=0, - status="fine") - # This shouldn't be needed, but at the moment the - # overrided methods are not called - self.connect ("started", self.started_cb) - - # Say to initable that we are ok - self.init (None) - - def started (self, x): - print "override started" - - def started_cb (self, x): - print "started as callback" - - def stopped (self): - print "override stopped" - - def resumed (self): - print "override resumed" - - def paused (self): - print "override paused" - - def progress (self): - print "override progress" - -if __name__ == "__main__": - m = MyMiner () - m.start () - - GObject.MainLoop().run () diff --git a/examples/introspection/python/query-async.py b/examples/introspection/python/query-async.py deleted file mode 100755 index 1077052dc..000000000 --- a/examples/introspection/python/query-async.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python -import gi -from gi.repository import Tracker, GObject - -def results_ready_cb (obj, result, user_data): - cursor = obj.query_finish (result) - - # This can also be done asynchronously - while (cursor.next (None)): - print cursor.get_string (0) - - user_data.quit () - - -if __name__ == "__main__": - loop = GObject.MainLoop () - - # The connection can be requested asynchronously - conn = Tracker.SparqlConnection.get (None) - conn.query_async ("SELECT nie:url(?u) WHERE { ?u a nfo:FileDataObject }", - None, - results_ready_cb, - loop) - - loop.run () diff --git a/examples/introspection/python/query-sync.py b/examples/introspection/python/query-sync.py deleted file mode 100755 index cf8bfd6f6..000000000 --- a/examples/introspection/python/query-sync.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python -import gi -from gi.repository import Tracker - -conn = Tracker.SparqlConnection.get (None) -cursor = conn.query ("SELECT ?u WHERE { ?u a nie:InformationElement. }", None) - -while (cursor.next (None)): - print cursor.get_string (0) diff --git a/examples/python/all-async.py b/examples/python/all-async.py new file mode 100755 index 000000000..70a3b2b1f --- /dev/null +++ b/examples/python/all-async.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +import gi +from gi.repository import Tracker, GObject + + +def results_ready_cb (obj, result, user_data): + cursor = obj.query_finish (result) + + # This can also be done asynchronously + while (cursor.next (None)): + print cursor.get_string (0) + + user_data.quit () + +def connection_ready_cb (object, result, user_data): + assert user_data + conn = Tracker.SparqlConnection.get_finish (result) + + conn.query_async ("SELECT ?u WHERE { ?u a nie:InformationElement. }", + None, + results_ready_cb, + user_data) + + +if __name__ == "__main__": + loop = GObject.MainLoop () + + Tracker.SparqlConnection.get_async (None, connection_ready_cb, loop) + + loop.run () diff --git a/examples/python/miner.py b/examples/python/miner.py new file mode 100755 index 000000000..8bc39d574 --- /dev/null +++ b/examples/python/miner.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +import gi +from gi.repository import TrackerMiner, GLib, GObject, Gio + + +class MyMiner (TrackerMiner.Miner): + __gtype_name__ = 'MyMiner' + + def __init__ (self): + TrackerMiner.Miner.__init__ (self, + name="MyMiner", + progress=0, + status="fine") + # This shouldn't be needed, but at the moment the + # overrided methods are not called + self.connect ("started", self.started_cb) + + # Say to initable that we are ok + self.init (None) + + def started (self, x): + print "override started" + + def started_cb (self, x): + print "started as callback" + + def stopped (self): + print "override stopped" + + def resumed (self): + print "override resumed" + + def paused (self): + print "override paused" + + def progress (self): + print "override progress" + +if __name__ == "__main__": + m = MyMiner () + m.start () + + GObject.MainLoop().run () diff --git a/examples/python/query-async.py b/examples/python/query-async.py new file mode 100755 index 000000000..1077052dc --- /dev/null +++ b/examples/python/query-async.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +import gi +from gi.repository import Tracker, GObject + +def results_ready_cb (obj, result, user_data): + cursor = obj.query_finish (result) + + # This can also be done asynchronously + while (cursor.next (None)): + print cursor.get_string (0) + + user_data.quit () + + +if __name__ == "__main__": + loop = GObject.MainLoop () + + # The connection can be requested asynchronously + conn = Tracker.SparqlConnection.get (None) + conn.query_async ("SELECT nie:url(?u) WHERE { ?u a nfo:FileDataObject }", + None, + results_ready_cb, + loop) + + loop.run () diff --git a/examples/python/query-sync.py b/examples/python/query-sync.py new file mode 100755 index 000000000..cf8bfd6f6 --- /dev/null +++ b/examples/python/query-sync.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python +import gi +from gi.repository import Tracker + +conn = Tracker.SparqlConnection.get (None) +cursor = conn.query ("SELECT ?u WHERE { ?u a nie:InformationElement. }", None) + +while (cursor.next (None)): + print cursor.get_string (0) -- cgit v1.2.1