python3.patch 122 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554
  1. diff -Naur zeitgeist-explorer-0.2.orig/setup.py zeitgeist-explorer-0.2/setup.py
  2. --- zeitgeist-explorer-0.2.orig/setup.py 2019-03-31 12:36:02.070003679 +0000
  3. +++ zeitgeist-explorer-0.2/setup.py 2019-03-31 12:40:06.760645118 +0000
  4. @@ -9,7 +9,7 @@
  5. results = []
  6. for src_dir in dirs:
  7. for root,dirs,files in os.walk(src_dir):
  8. - results.append((root, map(lambda f:root + "/" + f, files)))
  9. + results.append((root, [root + "/" + f for f in files]))
  10. return results
  11. DistUtilsExtra.auto.setup(
  12. diff -Naur zeitgeist-explorer-0.2.orig/zeitgeist-explorer zeitgeist-explorer-0.2/zeitgeist-explorer
  13. --- zeitgeist-explorer-0.2.orig/zeitgeist-explorer 2019-03-31 12:36:02.070003679 +0000
  14. +++ zeitgeist-explorer-0.2/zeitgeist-explorer 2019-03-31 13:37:32.529647820 +0000
  15. @@ -25,7 +25,7 @@
  16. from zgexplorer.window import ExplorerMainWindow
  17. def main():
  18. - gettext.install('zeitgeist-explorer', unicode=True)
  19. + gettext.install('zeitgeist-explorer')
  20. ExplorerMainWindow()
  21. Gtk.main()
  22. diff -Naur zeitgeist-explorer-0.2.orig/zgexplorer/applicationsviewer.py zeitgeist-explorer-0.2/zgexplorer/applicationsviewer.py
  23. --- zeitgeist-explorer-0.2.orig/zgexplorer/applicationsviewer.py 2019-03-31 12:36:02.066670337 +0000
  24. +++ zeitgeist-explorer-0.2/zgexplorer/applicationsviewer.py 2019-03-31 13:38:15.069764174 +0000
  25. @@ -27,7 +27,7 @@
  26. from zgexplorer.eventwidgets import EventDetailsViewer, EventsTreeView, EventsViewer
  27. from zgexplorer.remote import get_zeitgeist
  28. -from zeitgeist.datamodel import Event, Subject, Interpretation, \
  29. +from zgexplorer.datamodel import Event, Subject, Interpretation, \
  30. Manifestation, StorageState, ResultType, TimeRange
  31. class ApplicationsViewer(Gtk.VBox):
  32. @@ -124,7 +124,7 @@
  33. model, _iter = selection.get_selected()
  34. if _iter is not None:
  35. sel_actor = model.get(_iter, 0)[0]
  36. - question_name = self.actor_name[sel_actor] if self.actor_name.has_key(sel_actor) else sel_actor
  37. + question_name = self.actor_name[sel_actor] if sel_actor in self.actor_name else sel_actor
  38. question_text = "Do you want to remove all the events for Application '{0}'?".format(question_name)
  39. dialog = Gtk.MessageDialog(self.main_window, 0, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, question_text)
  40. response = dialog.run()
  41. @@ -293,8 +293,8 @@
  42. row = str(row)
  43. if ":" not in row:
  44. iters[str(row)] = self.apps.get_iter(row)
  45. - if len(iters.keys()) > 0:
  46. - for row, _iter in iters.items():
  47. + if len(list(iters.keys())) > 0:
  48. + for row, _iter in list(iters.items()):
  49. if _iter is not None:
  50. lis = model.get(_iter,0)[0]
  51. event = self.events[int(row)]
  52. diff -Naur zeitgeist-explorer-0.2.orig/zgexplorer/client.py zeitgeist-explorer-0.2/zgexplorer/client.py
  53. --- zeitgeist-explorer-0.2.orig/zgexplorer/client.py 1970-01-01 00:00:00.000000000 +0000
  54. +++ zeitgeist-explorer-0.2/zgexplorer/client.py 2019-03-31 13:36:23.009456693 +0000
  55. @@ -0,0 +1,1103 @@
  56. +# -.- coding: utf-8 -.-
  57. +
  58. +# Zeitgeist
  59. +#
  60. +# Copyright © 2009-2011 Siegfried-Angel Gevatter Pujals <siegfried@gevatter.com>
  61. +# Copyright © 2009 Mikkel Kamstrup Erlandsen <mikkel.kamstrup@gmail.com>
  62. +# Copyright © 2009-2011 Markus Korn <thekorn@gmx.de>
  63. +# Copyright © 2011 Collabora Ltd.
  64. +# By Siegfried-Angel Gevatter Pujals <siegfried@gevatter.com>
  65. +#
  66. +# This program is free software: you can redistribute it and/or modify
  67. +# it under the terms of the GNU Lesser General Public License as published by
  68. +# the Free Software Foundation, either version 2.1 of the License, or
  69. +# (at your option) any later version.
  70. +#
  71. +# This program is distributed in the hope that it will be useful,
  72. +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  73. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  74. +# GNU Lesser General Public License for more details.
  75. +#
  76. +# You should have received a copy of the GNU Lesser General Public License
  77. +# along with this program. If not, see <http://www.gnu.org/licenses/>.
  78. +
  79. +import dbus
  80. +import dbus.service
  81. +import dbus.mainloop.glib
  82. +import logging
  83. +import os.path
  84. +import sys
  85. +import inspect
  86. +
  87. +from xml.etree import ElementTree
  88. +
  89. +dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
  90. +
  91. +from zgexplorer.datamodel import (Event, Subject, TimeRange, StorageState,
  92. + ResultType)
  93. +
  94. +SIG_EVENT = "asaasay"
  95. +
  96. +log = logging.getLogger("zeitgeist.client")
  97. +
  98. +# This is here so testutils.py can override it with a private bus connection.
  99. +# Init needs to be lazy so tests will use the private D-Bus instance.
  100. +global session_bus
  101. +session_bus = None
  102. +def get_bus():
  103. + global session_bus
  104. + if session_bus is None:
  105. + session_bus = dbus.SessionBus()
  106. + return session_bus
  107. +def _set_bus(bus):
  108. + global session_bus
  109. + session_bus = bus
  110. +
  111. +class _DBusInterface(object):
  112. + """Wrapper around dbus.Interface adding convenience methods."""
  113. +
  114. + # We initialize those as sets in the constructor. Remember that we can't do
  115. + # that here because otherwise all instances would share their state.
  116. + _disconnect_callbacks = None
  117. + _reconnect_callbacks = None
  118. +
  119. + @staticmethod
  120. + def get_members(introspection_xml):
  121. + """Parses the XML context returned by Introspect() and returns
  122. + a tuple, where the first item is a list of all methods and the
  123. + second one a list of all signals for the related interface
  124. + """
  125. + xml = ElementTree.fromstring(introspection_xml)
  126. + nodes = xml.findall("interface/signal")
  127. + signals = [node.attrib["name"] for node in nodes]
  128. + nodes = xml.findall("interface/method")
  129. + methods = [node.attrib["name"] for node in nodes]
  130. + try:
  131. + methods.remove("Introspect") # Introspect is not part of the API
  132. + except ValueError:
  133. + pass
  134. + return methods, signals
  135. +
  136. + def reconnect(self):
  137. + if not self._reconnect_when_needed:
  138. + return
  139. + self.__proxy = get_bus().get_object(
  140. + self.__iface.requested_bus_name, self.__object_path,
  141. + follow_name_owner_changes=True)
  142. + self.__iface = dbus.Interface(self.__proxy, self.__interface_name)
  143. + self._load_introspection_data()
  144. +
  145. + def _disconnection_safe(self, method_getter, *args, **kwargs):
  146. + """
  147. + Executes the method returned by method_getter. If it fails because
  148. + the D-Bus connection was lost, it attempts to recover it and executes
  149. + the method again.
  150. + """
  151. +
  152. + custom_error_handler = None
  153. + original_kwargs = dict(kwargs)
  154. +
  155. + def reconnecting_error_handler(e):
  156. + error = e.get_dbus_name()
  157. + if error == "org.freedesktop.DBus.Error.ServiceUnknown":
  158. + self.reconnect()
  159. + # We don't use the reconnecting_error_handler here since that'd
  160. + # get us into an endless loop if Zeitgeist really isn't there.
  161. + return method_getter()(*args, **original_kwargs)
  162. + else:
  163. + if custom_error_handler is not None:
  164. + custom_error_handler(e)
  165. + else:
  166. + raise
  167. +
  168. + if 'error_handler' in kwargs:
  169. + # If the method is being called asynchronously it'll call the given
  170. + # handler on failure instead of directly raising an exception.
  171. + custom_error_handler = kwargs['error_handler']
  172. + kwargs['error_handler'] = reconnecting_error_handler
  173. +
  174. + try:
  175. + return method_getter()(*args, **kwargs)
  176. + except dbus.exceptions.DBusException as e:
  177. + return reconnecting_error_handler(e)
  178. +
  179. + def __getattr__(self, name):
  180. + if self.__methods is not None and name not in self.__methods:
  181. + raise TypeError("Unknown method name: %s" % name)
  182. + def _ProxyMethod(*args, **kwargs):
  183. + """
  184. + Method wrapping around a D-Bus call, which attempts to recover
  185. + the connection to Zeitgeist if it got lost.
  186. + """
  187. + return self._disconnection_safe(
  188. + lambda: getattr(self.__iface, name), *args, **kwargs)
  189. + return _ProxyMethod
  190. +
  191. + def get_property(self, property_name):
  192. + return self._disconnection_safe(
  193. + lambda: self.__proxy.get_dbus_method("Get", dbus.PROPERTIES_IFACE),
  194. + self.__interface_name, property_name)
  195. +
  196. + def connect(self, signal, callback, **kwargs):
  197. + """Connect a callback to a signal of the current proxy instance."""
  198. + if self.__signals is None:
  199. + self.reconnect()
  200. + if signal not in self.__signals:
  201. + raise TypeError("Unknown signal name: %s" % signal)
  202. + return self.__proxy.connect_to_signal(
  203. + signal,
  204. + callback,
  205. + dbus_interface=self.__interface_name,
  206. + **kwargs)
  207. +
  208. + def connect_exit(self, callback):
  209. + """Executes callback when the remote interface disappears from the bus"""
  210. + self._disconnect_callbacks.add(callback)
  211. +
  212. + def connect_join(self, callback):
  213. + """
  214. + Executes callback when someone claims the Zeitgeist D-Bus name.
  215. + This may be used to perform some action if the daemon is restarted while
  216. + it was being used.
  217. + """
  218. + self._reconnect_callbacks.add(callback)
  219. +
  220. + @property
  221. + def proxy(self):
  222. + return self.__proxy
  223. +
  224. + def _load_introspection_data(self):
  225. + self.__methods, self.__signals = self.get_members(
  226. + self.__proxy.Introspect(
  227. + dbus_interface='org.freedesktop.DBus.Introspectable'))
  228. +
  229. + def __init__(self, proxy, interface_name, object_path, reconnect=True):
  230. + self.__proxy = proxy
  231. + self.__interface_name = interface_name
  232. + self.__object_path = object_path
  233. + self.__iface = dbus.Interface(proxy, interface_name)
  234. + self._reconnect_when_needed = reconnect
  235. + self._load_introspection_data()
  236. +
  237. + self._first_connection = True
  238. + self._disconnect_callbacks = set()
  239. + self._reconnect_callbacks = set()
  240. +
  241. + # Listen to (dis)connection notifications, for connect_exit and connect_join
  242. + def name_owner_changed(connection_name):
  243. + if connection_name == "":
  244. + self.__methods = self.__signals = None
  245. + for callback in self._disconnect_callbacks:
  246. + callback()
  247. + elif self._first_connection:
  248. + # python-dbus guarantees that it'll call NameOwnerChanged at startup
  249. + # (even if the service was already running). When that happens, we
  250. + # don't want to connect the signals a second time.
  251. + self._first_connection = False
  252. + else:
  253. + if not self._reconnect_when_needed:
  254. + return
  255. + self.reconnect()
  256. + for callback in self._reconnect_callbacks:
  257. + callback()
  258. + get_bus().watch_name_owner(self.__iface.requested_bus_name,
  259. + name_owner_changed)
  260. +
  261. +class ZeitgeistDBusInterface(object):
  262. + """ Central DBus interface to the Zeitgeist engine
  263. +
  264. + There does not necessarily have to be one single instance of this
  265. + interface class, but all instances should share the same state
  266. + (like use the same bus and be connected to the same proxy). This is
  267. + achieved by extending the `Borg Pattern` as described by Alex Martelli
  268. + """
  269. + __shared_state = {}
  270. +
  271. + BUS_NAME = "org.gnome.zeitgeist.Engine"
  272. + INTERFACE_NAME = "org.gnome.zeitgeist.Log"
  273. + OBJECT_PATH = "/org/gnome/zeitgeist/log/activity"
  274. +
  275. + def __getattr__(self, name):
  276. + return getattr(self.__shared_state["dbus_interface"], name)
  277. +
  278. + def version(self):
  279. + """Returns the API version"""
  280. + dbus_interface = self.__shared_state["dbus_interface"]
  281. + return dbus_interface.get_property("version")
  282. +
  283. + def extensions(self):
  284. + """Returns active extensions"""
  285. + dbus_interface = self.__shared_state["dbus_interface"]
  286. + return dbus_interface.get_property("extensions")
  287. +
  288. + def get_extension(cls, name, path, busname=None):
  289. + """ Returns an interface to the given extension.
  290. +
  291. + Example usage:
  292. + >> reg = get_extension("DataSourceRegistry", "data_source_registry")
  293. + >> reg.RegisterDataSource(...)
  294. + """
  295. + if busname:
  296. + busname = "org.gnome.zeitgeist.%s" % busname
  297. + else:
  298. + busname = cls.BUS_NAME
  299. + if not name in cls.__shared_state["extension_interfaces"]:
  300. + interface_name = "org.gnome.zeitgeist.%s" % name
  301. + object_path = "/org/gnome/zeitgeist/%s" % path
  302. + proxy = get_bus().get_object(busname, object_path,
  303. + follow_name_owner_changes=True)
  304. + iface = _DBusInterface(proxy, interface_name, object_path)
  305. + iface.BUS_NAME = busname
  306. + iface.INTERFACE_NAME = interface_name
  307. + iface.OBJECT_PATH = object_path
  308. + cls.__shared_state["extension_interfaces"][name] = iface
  309. + return cls.__shared_state["extension_interfaces"][name]
  310. +
  311. + def __init__(self, reconnect=True):
  312. + if not "dbus_interface" in self.__shared_state:
  313. + try:
  314. + proxy = get_bus().get_object(self.BUS_NAME,
  315. + self.OBJECT_PATH, follow_name_owner_changes=True)
  316. + except dbus.exceptions.DBusException as e:
  317. + if e.get_dbus_name() == "org.freedesktop.DBus.Error.ServiceUnknown":
  318. + raise RuntimeError(
  319. + "Found no running zeitgeist-daemon instance: %s" % \
  320. + e.get_dbus_message())
  321. + else:
  322. + raise
  323. + self.__shared_state["extension_interfaces"] = {}
  324. + self.__shared_state["dbus_interface"] = _DBusInterface(proxy,
  325. + self.INTERFACE_NAME, self.OBJECT_PATH, reconnect)
  326. +
  327. +class Monitor(dbus.service.Object):
  328. + """
  329. + DBus interface for monitoring the Zeitgeist log for certain types
  330. + of events.
  331. +
  332. + When using the Python bindings monitors are normally instantiated
  333. + indirectly by calling :meth:`ZeitgeistClient.install_monitor`.
  334. +
  335. + It is important to understand that the Monitor instance lives on the
  336. + client side, and expose a DBus service there, and the Zeitgeist engine
  337. + calls back to the monitor when matching events are registered.
  338. + """
  339. +
  340. + # Used in Monitor._next_path() to generate unique path names
  341. + _last_path_id = 0
  342. +
  343. + _event_type = Event
  344. +
  345. + def __init__ (self, time_range, event_templates, insert_callback,
  346. + delete_callback, monitor_path=None, event_type=None):
  347. + if not monitor_path:
  348. + monitor_path = Monitor._next_path()
  349. + elif isinstance(monitor_path, str):
  350. + monitor_path = dbus.ObjectPath(monitor_path)
  351. +
  352. + if event_type:
  353. + if not issubclass(event_type, Event):
  354. + raise TypeError("Event subclass expected.")
  355. + self._event_type = event_type
  356. +
  357. + self._time_range = time_range
  358. + self._templates = event_templates
  359. + self._path = monitor_path
  360. + self._insert_callback = insert_callback
  361. + self._delete_callback = delete_callback
  362. + dbus.service.Object.__init__(self, get_bus(), monitor_path)
  363. +
  364. + def get_path (self): return self._path
  365. + path = property(get_path,
  366. + doc="Read only property with the DBus path of the monitor object")
  367. +
  368. + def get_time_range(self): return self._time_range
  369. + time_range = property(get_time_range,
  370. + doc="Read only property with the :class:`TimeRange` matched by this monitor")
  371. +
  372. + def get_templates (self): return self._templates
  373. + templates = property(get_templates,
  374. + doc="Read only property with installed templates")
  375. +
  376. + @dbus.service.method("org.gnome.zeitgeist.Monitor",
  377. + in_signature="(xx)a("+SIG_EVENT+")")
  378. + def NotifyInsert(self, time_range, events):
  379. + """
  380. + Receive notification that a set of events matching the monitor's
  381. + templates has been recorded in the log.
  382. +
  383. + This method is the raw DBus callback and should normally not be
  384. + overridden. Events are received via the *insert_callback*
  385. + argument given in the constructor to this class.
  386. +
  387. + :param time_range: A two-tuple of 64 bit integers with the minimum
  388. + and maximum timestamps found in *events*. DBus signature (xx)
  389. + :param events: A list of DBus event structs, signature a(asaasay)
  390. + with the events matching the monitor.
  391. + See :meth:`ZeitgeistClient.install_monitor`
  392. + """
  393. + self._insert_callback(TimeRange(time_range[0], time_range[1]),
  394. + list(map(self._event_type, events)))
  395. +
  396. + @dbus.service.method("org.gnome.zeitgeist.Monitor",
  397. + in_signature="(xx)au")
  398. + def NotifyDelete(self, time_range, event_ids):
  399. + """
  400. + Receive notification that a set of events within the monitor's
  401. + matched time range has been deleted. Note that this notification
  402. + will also be emitted for deleted events that doesn't match the
  403. + event templates of the monitor. It's just the time range which
  404. + is considered here.
  405. +
  406. + This method is the raw DBus callback and should normally not be
  407. + overridden. Events are received via the *delete_callback*
  408. + argument given in the constructor to this class.
  409. +
  410. + :param time_range: A two-tuple of 64 bit integers with the minimum
  411. + and maximum timestamps found in *events*. DBus signature (xx)
  412. + :param event_ids: A list of event ids. An event id is simply
  413. + and unsigned 32 bit integer. DBus signature au.
  414. + """
  415. + self._delete_callback(TimeRange(time_range[0], time_range[1]), event_ids)
  416. +
  417. + def __hash__ (self):
  418. + return hash(self._path)
  419. +
  420. + @classmethod
  421. + def _next_path(cls):
  422. + """
  423. + Generate a new unique DBus object path for a monitor
  424. + """
  425. + cls._last_path_id += 1
  426. + return dbus.ObjectPath("/org/gnome/zeitgeist/monitor/%s" % \
  427. + cls._last_path_id)
  428. +
  429. +class ZeitgeistClient:
  430. + """
  431. + Convenience APIs to have a Pythonic way to call and monitor the running
  432. + Zeitgeist engine. For raw DBus access use the
  433. + :class:`ZeitgeistDBusInterface` class.
  434. +
  435. + Note that this class only does asynchronous DBus calls. This is almost
  436. + always the right thing to do. If you really want to do synchronous
  437. + DBus calls use the raw DBus API found in the ZeitgeistDBusInterface class.
  438. + """
  439. +
  440. + _installed_monitors = []
  441. + _event_type = Event
  442. +
  443. + @staticmethod
  444. + def get_event_and_extra_arguments(arguments):
  445. + """ some methods of :class:`ZeitgeistClient` take a variable
  446. + number of arguments, where one part of the arguments are used
  447. + to build one :class:`Event` instance and the other part
  448. + is forwarded to another method. This function returns an event
  449. + and the remaining arguments."""
  450. + kwargs = {}
  451. + for arg in _FIND_EVENTS_FOR_TEMPLATES_ARGS:
  452. + if arg in arguments:
  453. + kwargs[arg] = arguments.pop(arg)
  454. + ev = Event.new_for_values(**arguments)
  455. + return ev, kwargs
  456. +
  457. + def __init__ (self):
  458. + self._iface = ZeitgeistDBusInterface()
  459. + self._registry = self._iface.get_extension("DataSourceRegistry",
  460. + "data_source_registry")
  461. +
  462. + # Reconnect all active monitors if the connection is reset.
  463. + def reconnect_monitors():
  464. + log.info("Reconnected to Zeitgeist engine...")
  465. + for monitor in self._installed_monitors:
  466. + self._iface.InstallMonitor(monitor.path,
  467. + monitor.time_range,
  468. + monitor.templates,
  469. + reply_handler=self._void_reply_handler,
  470. + error_handler=lambda err: log.warn(
  471. + "Error reinstalling monitor: %s" % err))
  472. + self._iface.connect_join(reconnect_monitors)
  473. +
  474. + def register_event_subclass(self, event_type):
  475. + """
  476. + Register a subclass of Event with this ZeiteistClient instance. When
  477. + data received over D-Bus is instantiated into an Event object, the
  478. + provided subclass will be used.
  479. + """
  480. + if not issubclass(event_type, Event):
  481. + raise TypeError("Event subclass expected.")
  482. + self._event_type = event_type
  483. +
  484. + def register_subject_subclass(self, subject_type):
  485. + """
  486. + Register a subclass of Subject with this ZeiteistClient instance. When
  487. + data received over D-Bus is instantiated into a Subject object, the
  488. + provided subclass will be used.
  489. +
  490. + Note that this method works by changing the Event type associated with
  491. + this ZeitgeistClient instance, so it should always be called *after*
  492. + any register_event_subclass calls.
  493. +
  494. + Even better, if you also have a custom Event subclass, you may directly
  495. + override the Subject type by changing its _subject_type class variable.
  496. + """
  497. + if not issubclass(subject_type, Subject):
  498. + raise TypeError("Subject subclass expected.")
  499. + class EventWithCustomSubject(self._event_type):
  500. + _subject_type = subject_type
  501. + self._event_type = EventWithCustomSubject
  502. +
  503. + def _safe_error_handler(self, error_handler, *args):
  504. + if error_handler is not None:
  505. + if callable(error_handler):
  506. + return error_handler
  507. + raise TypeError(
  508. + "Error handler not callable, found %s" % error_handler)
  509. + return lambda raw: self._stderr_error_handler(raw, *args)
  510. +
  511. + def _safe_reply_handler(self, reply_handler):
  512. + if reply_handler is not None:
  513. + if callable(reply_handler):
  514. + return reply_handler
  515. + raise TypeError(
  516. + "Reply handler not callable, found %s" % reply_handler)
  517. + return self._void_reply_handler
  518. +
  519. + # Properties
  520. +
  521. + def get_version(self):
  522. + return [int(i) for i in self._iface.version()]
  523. +
  524. + def get_extensions(self):
  525. + return [str(i) for i in self._iface.extensions()]
  526. +
  527. + # Methods
  528. +
  529. + def insert_event (self, event, ids_reply_handler=None, error_handler=None):
  530. + """
  531. + Send an event to the Zeitgeist event log. The 'event' parameter
  532. + must be an instance of the Event class.
  533. +
  534. + The insertion will be done via an asynchronous DBus call and
  535. + this method will return immediately. This means that the
  536. + Zeitgeist engine will most likely not have inserted the event
  537. + when this method returns. There will be a short delay.
  538. +
  539. + If the ids_reply_handler argument is set to a callable it will
  540. + be invoked with a list containing the ids of the inserted events
  541. + when they have been registered in Zeitgeist.
  542. +
  543. + In case of errors a message will be printed on stderr, and
  544. + an empty result passed to ids_reply_handler (if set).
  545. + To override this default set the error_handler named argument
  546. + to a callable that takes a single exception as its sole
  547. + argument.
  548. +
  549. + In order to use this method there needs to be a mainloop
  550. + runnning. Both Qt and GLib mainloops are supported.
  551. + """
  552. + self.insert_events([event],
  553. + ids_reply_handler=ids_reply_handler,
  554. + error_handler=error_handler)
  555. +
  556. + def insert_event_for_values (self, **values):
  557. + """
  558. + Send an event to the Zeitgeist event log. The keyword arguments
  559. + must match those as provided to Event.new_for_values().
  560. +
  561. + The insertion will be done via an asynchronous DBus call and
  562. + this method will return immediately. This means that the
  563. + Zeitgeist engine will most likely not have inserted the event
  564. + when this method returns. There will be a short delay.
  565. +
  566. + If the ids_reply_handler argument is set to a callable it will
  567. + be invoked with a list containing the ids of the inserted events
  568. + when they have been registered in Zeitgeist.
  569. +
  570. + In case of errors a message will be printed on stderr, and
  571. + an empty result passed to ids_reply_handler (if set).
  572. + To override this default set the error_handler named argument
  573. + to a callable that takes a single exception as its sole
  574. + argument.
  575. +
  576. + In order to use this method there needs to be a mainloop
  577. + runnning. Both Qt and GLib mainloops are supported.
  578. + """
  579. + ev = Event.new_for_values(**values)
  580. + self.insert_events([ev],
  581. + values.get("ids_reply_handler", None),
  582. + values.get("error_handler", None))
  583. +
  584. + def insert_events (self, events, ids_reply_handler=None, error_handler=None):
  585. + """
  586. + Send a collection of events to the Zeitgeist event log. The
  587. + *events* parameter must be a list or tuple containing only
  588. + members of of type :class:`Event <zeitgeist.datamodel.Event>`.
  589. +
  590. + The insertion will be done via an asynchronous DBus call and
  591. + this method will return immediately. This means that the
  592. + Zeitgeist engine will most likely not have inserted the events
  593. + when this method returns. There will be a short delay.
  594. +
  595. + In case of errors a message will be printed on stderr, and
  596. + an empty result passed to *ids_reply_handler* (if set).
  597. + To override this default set the *error_handler* named argument
  598. + to a callable that takes a single exception as its sole
  599. + argument.
  600. +
  601. + In order to use this method there needs to be a mainloop
  602. + runnning. Both Qt and GLib mainloops are supported.
  603. + """
  604. +
  605. + self._check_list_or_tuple(events)
  606. + self._check_members(events, Event)
  607. + self._iface.InsertEvents(events,
  608. + reply_handler=self._safe_reply_handler(ids_reply_handler),
  609. + error_handler=self._safe_error_handler(error_handler,
  610. + self._safe_reply_handler(ids_reply_handler), []))
  611. +
  612. + def find_event_ids_for_templates (self,
  613. + event_templates,
  614. + ids_reply_handler,
  615. + timerange = None,
  616. + storage_state = StorageState.Any,
  617. + num_events = 20,
  618. + result_type = ResultType.MostRecentEvents,
  619. + error_handler=None):
  620. + """
  621. + Send a query matching a collection of
  622. + :class:`Event <zeitgeist.datamodel.Event>` templates to the
  623. + Zeitgeist event log. The query will match if an event matches
  624. + any of the templates. If an event template has more
  625. + than one subject the query will match if any one of the subject
  626. + templates match.
  627. +
  628. + The query will be done via an asynchronous DBus call and
  629. + this method will return immediately. The return value
  630. + will be passed to 'ids_reply_handler' as a list
  631. + of integer event ids. This list must be the sole argument for
  632. + the callback.
  633. +
  634. + The actual :class:`Events` can be looked up via the
  635. + :meth:`get_events()` method.
  636. +
  637. + This method is intended for queries potentially returning a
  638. + large result set. It is especially useful in cases where only
  639. + a portion of the results are to be displayed at the same time
  640. + (eg., by using paging or dynamic scrollbars), as by holding a
  641. + list of IDs you keep a stable ordering, and you can ask for
  642. + the details associated to them in batches, when you need them. For
  643. + queries with a small amount of results, or where you need the
  644. + information about all results at once no matter how many of them
  645. + there are, see :meth:`find_events_for_templates`.
  646. +
  647. + In case of errors a message will be printed on stderr, and
  648. + an empty result passed to ids_reply_handler.
  649. + To override this default set the error_handler named argument
  650. + to a callable that takes a single exception as its sole
  651. + argument.
  652. +
  653. + In order to use this method there needs to be a mainloop
  654. + runnning. Both Qt and GLib mainloops are supported.
  655. +
  656. + :param event_templates: List or tuple of
  657. + :class:`Event <zeitgeist.datamodel.Event>` instances
  658. + :param ids_reply_handler: Callable taking a list of integers
  659. + :param timerange: A
  660. + :class:`TimeRange <zeitgeist.datamodel.TimeRange>` instance
  661. + that the events must have occured within. Defaults to
  662. + :meth:`TimeRange.until_now()`.
  663. + :param storage_state: A value from the
  664. + :class:`StorageState <zeitgeist.datamodel.StorageState>`
  665. + enumeration. Defaults to :const:`StorageState.Any`
  666. + :param num_events: The number of events to return; default is 20
  667. + :param result_type: A value from the
  668. + :class:`ResultType <zeitgeist.datamodel.ResultType>`
  669. + enumeration. Defaults to ResultType.MostRecentEvent
  670. + :param error_handler: Callback to catch error messages.
  671. + Read about the default behaviour above
  672. + """
  673. + self._check_list_or_tuple(event_templates)
  674. + self._check_members(event_templates, Event)
  675. +
  676. + if not callable(ids_reply_handler):
  677. + raise TypeError(
  678. + "Reply handler not callable, found %s" % ids_reply_handler)
  679. +
  680. + if timerange is None:
  681. + timerange = TimeRange.until_now()
  682. +
  683. + self._iface.FindEventIds(timerange,
  684. + event_templates,
  685. + storage_state,
  686. + num_events,
  687. + result_type,
  688. + reply_handler=self._safe_reply_handler(ids_reply_handler),
  689. + error_handler=self._safe_error_handler(error_handler,
  690. + ids_reply_handler, []))
  691. +
  692. + def find_event_ids_for_template (self, event_template, ids_reply_handler,
  693. + **kwargs):
  694. + """
  695. + Alias for :meth:`find_event_ids_for_templates`, for use when only
  696. + one template is needed.
  697. + """
  698. + self.find_event_ids_for_templates([event_template],
  699. + ids_reply_handler,
  700. + **kwargs)
  701. +
  702. + def find_event_ids_for_values(self, ids_reply_handler, **kwargs):
  703. + """
  704. + Alias for :meth:`find_event_ids_for_templates`, for when only
  705. + one template is needed. Instead of taking an already created
  706. + template, like :meth:`find_event_ids_for_template`, this method
  707. + will construct the template from the parameters it gets. The
  708. + allowed keywords are the same as the ones allowed by
  709. + :meth:`Event.new_for_values() <zeitgeist.datamodel.Event.new_for_values>`.
  710. + """
  711. + ev, arguments = self.get_event_and_extra_arguments(kwargs)
  712. + self.find_event_ids_for_templates([ev],
  713. + ids_reply_handler,
  714. + **arguments)
  715. +
  716. + def find_events_for_templates (self,
  717. + event_templates,
  718. + events_reply_handler,
  719. + timerange = None,
  720. + storage_state = StorageState.Any,
  721. + num_events = 20,
  722. + result_type = ResultType.MostRecentEvents,
  723. + error_handler=None):
  724. + """
  725. + Send a query matching a collection of
  726. + :class:`Event <zeitgeist.datamodel.Event>` templates to the
  727. + Zeitgeist event log. The query will match if an event matches
  728. + any of the templates. If an event template has more
  729. + than one subject the query will match if any one of the subject
  730. + templates match.
  731. +
  732. + The query will be done via an asynchronous DBus call and
  733. + this method will return immediately. The return value
  734. + will be passed to 'events_reply_handler' as a list
  735. + of :class:`Event`s. This list must be the sole argument for
  736. + the callback.
  737. +
  738. + If you need to do a query yielding a large (or unpredictable)
  739. + result set and you only want to show some of the results at the
  740. + same time (eg., by paging them), consider using
  741. + :meth:`find_event_ids_for_templates`.
  742. +
  743. + In case of errors a message will be printed on stderr, and
  744. + an empty result passed to events_reply_handler.
  745. + To override this default set the error_handler named argument
  746. + to a callable that takes a single exception as its sole
  747. + argument.
  748. +
  749. + In order to use this method there needs to be a mainloop
  750. + runnning. Both Qt and GLib mainloops are supported.
  751. +
  752. + :param event_templates: List or tuple of
  753. + :class:`Event <zeitgeist.datamodel.Event>` instances
  754. + :param events_reply_handler: Callable taking a list of integers
  755. + :param timerange: A
  756. + :class:`TimeRange <zeitgeist.datamodel.TimeRange>` instance
  757. + that the events must have occured within. Defaults to
  758. + :meth:`TimeRange.until_now()`.
  759. + :param storage_state: A value from the
  760. + :class:`StorageState <zeitgeist.datamodel.StorageState>`
  761. + enumeration. Defaults to :const:`StorageState.Any`
  762. + :param num_events: The number of events to return; default is 20
  763. + :param result_type: A value from the
  764. + :class:`ResultType <zeitgeist.datamodel.ResultType>`
  765. + enumeration. Defaults to ResultType.MostRecentEvent
  766. + :param error_handler: Callback to catch error messages.
  767. + Read about the default behaviour above
  768. + """
  769. + self._check_list_or_tuple(event_templates)
  770. + self._check_members(event_templates, Event)
  771. +
  772. + if not callable(events_reply_handler):
  773. + raise TypeError(
  774. + "Reply handler not callable, found %s" % events_reply_handler)
  775. +
  776. + if timerange is None:
  777. + timerange = TimeRange.until_now()
  778. +
  779. + self._iface.FindEvents(timerange,
  780. + event_templates,
  781. + storage_state,
  782. + num_events,
  783. + result_type,
  784. + reply_handler=lambda raw: events_reply_handler(
  785. + list(map(self._event_type.new_for_struct, raw))),
  786. + error_handler=self._safe_error_handler(error_handler,
  787. + events_reply_handler, []))
  788. +
  789. + def find_events_for_template (self, event_template, events_reply_handler,
  790. + **kwargs):
  791. + """
  792. + Alias for :meth:`find_events_for_templates`, for use when only
  793. + one template is needed.
  794. + """
  795. + self.find_events_for_templates([event_template],
  796. + events_reply_handler,
  797. + **kwargs)
  798. +
  799. + def find_events_for_values(self, events_reply_handler, **kwargs):
  800. + """
  801. + Alias for :meth:`find_events_for_templates`, for when only
  802. + one template is needed. Instead of taking an already created
  803. + template, like :meth:`find_event_ids_for_template`, this method
  804. + will construct the template from the parameters it gets. The
  805. + allowed keywords are the same as the ones allowed by
  806. + :meth:`Event.new_for_values() <zeitgeist.datamodel.Event.new_for_values>`.
  807. + """
  808. + ev, arguments = self.get_event_and_extra_arguments(kwargs)
  809. + self.find_events_for_templates([ev],
  810. + events_reply_handler,
  811. + **arguments)
  812. +
  813. + def get_events (self, event_ids, events_reply_handler, error_handler=None):
  814. + """
  815. + Look up a collection of :class:`Events <zeitgeist.datamodel.Event>`
  816. + in the Zeitgeist event log given a collection of event ids.
  817. + This is useful for looking up the event data for events found
  818. + with the *find_event_ids_** family of functions.
  819. +
  820. + Each event which is not found in the event log is represented
  821. + by `None` in the resulting collection.
  822. +
  823. + The query will be done via an asynchronous DBus call and
  824. + this method will return immediately. The returned events
  825. + will be passed to *events_reply_handler* as a list
  826. + of Events, which must be the only argument of the function.
  827. +
  828. + In case of errors a message will be printed on stderr, and
  829. + an empty result passed to *events_reply_handler*.
  830. + To override this default set the *error_handler* named argument
  831. + to a callable that takes a single exception as its sole
  832. + argument.
  833. +
  834. + In order to use this method there needs to be a mainloop
  835. + runnning. Both Qt and GLib mainloops are supported.
  836. + """
  837. +
  838. + if not callable(events_reply_handler):
  839. + raise TypeError(
  840. + "Reply handler not callable, found %s" % events_reply_handler)
  841. +
  842. + # Generate a wrapper callback that does automagic conversion of
  843. + # the raw DBus reply into a list of Event instances
  844. + self._iface.GetEvents(event_ids,
  845. + reply_handler=lambda raw: events_reply_handler(
  846. + list(map(self._event_type.new_for_struct, raw))),
  847. + error_handler=self._safe_error_handler(error_handler,
  848. + events_reply_handler, []))
  849. +
  850. + def delete_events(self, event_ids, reply_handler=None, error_handler=None):
  851. + """
  852. + Warning: This API is EXPERIMENTAL and is not fully supported yet.
  853. +
  854. + Delete a collection of events from the zeitgeist log given their
  855. + event ids.
  856. +
  857. + The deletion will be done asynchronously, and this method returns
  858. + immediately. To check whether the deletions went well supply
  859. + the *reply_handler* and/or *error_handler* funtions. The
  860. + reply handler should not take any argument. The error handler
  861. + must take a single argument - being the error.
  862. +
  863. + With custom handlers any errors will be printed to stderr.
  864. +
  865. + In order to use this method there needs to be a mainloop
  866. + runnning.
  867. + """
  868. + self._check_list_or_tuple(event_ids)
  869. + # we need dbus.UInt32 here as long as dbus.UInt32 is not a subtype
  870. + # of int, this might change in the future, see docstring of dbus.UInt32
  871. + self._check_members(event_ids, (int, dbus.UInt32))
  872. +
  873. + self._iface.DeleteEvents(event_ids,
  874. + reply_handler=self._safe_reply_handler(reply_handler),
  875. + error_handler=self._safe_error_handler(error_handler))
  876. +
  877. + def find_related_uris_for_events(self, event_templates, uris_reply_handler,
  878. + error_handler=None, time_range = None, result_event_templates=[],
  879. + storage_state=StorageState.Any, num_events=10, result_type=0):
  880. + """
  881. + Warning: This API is EXPERIMENTAL and is not fully supported yet.
  882. +
  883. + Get a list of URIs of subjects which frequently occur together
  884. + with events matching `event_templates`. Possibly restricting to
  885. + `time_range` or to URIs that occur as subject of events matching
  886. + `result_event_templates`.
  887. +
  888. + :param event_templates: Templates for events that you want to
  889. + find URIs that relate to
  890. + :param uris_reply_handler: A callback that takes a list of strings
  891. + with the URIs of the subjects related to the requested events
  892. + :param time_range: A :class:`TimeRange <zeitgeist.datamodel.TimeRange>`
  893. + to restrict to
  894. + :param result_event_templates: The related URIs must occur
  895. + as subjects of events matching these templates
  896. + :param storage_state: The returned URIs must have this
  897. + :class:`storage state <zeitgeist.datamodel.StorageState>`
  898. + :param num_events: number of related uris you want to have returned
  899. + :param result_type: sorting of the results by
  900. + 0 for relevancy
  901. + 1 for recency
  902. + :param error_handler: An optional callback in case of errors.
  903. + Must take a single argument being the error raised by the
  904. + server. The default behaviour in case of errors is to call
  905. + `uris_reply_handler` with an empty list and print an error
  906. + message on standard error.
  907. + """
  908. + if not callable(uris_reply_handler):
  909. + raise TypeError(
  910. + "Reply handler not callable, found %s" % uris_reply_handler)
  911. +
  912. + if time_range is None:
  913. + time_range = TimeRange.until_now()
  914. +
  915. + self._iface.FindRelatedUris(time_range, event_templates,
  916. + result_event_templates, storage_state, num_events, result_type,
  917. + reply_handler=self._safe_reply_handler(uris_reply_handler),
  918. + error_handler=self._safe_error_handler(error_handler,
  919. + uris_reply_handler,
  920. + [])
  921. + )
  922. +
  923. + def find_related_uris_for_uris(self, subject_uris, uris_reply_handler,
  924. + time_range=None, result_event_templates=[],
  925. + storage_state=StorageState.Any, num_events=10, result_type=0, error_handler=None):
  926. + """
  927. + Warning: This API is EXPERIMENTAL and is not fully supported yet.
  928. +
  929. + Same as :meth:`find_related_uris_for_events`, but taking a list
  930. + of subject URIs instead of event templates.
  931. + """
  932. +
  933. + event_template = Event.new_for_values(subjects=
  934. + [Subject.new_for_values(uri=uri) for uri in subject_uris])
  935. +
  936. + self.find_related_uris_for_events([event_template],
  937. + uris_reply_handler,
  938. + time_range=time_range,
  939. + result_event_templates=result_event_templates,
  940. + storage_state=storage_state,
  941. + num_events = num_events,
  942. + result_type = result_type,
  943. + error_handler=error_handler)
  944. +
  945. + def install_monitor (self, time_range, event_templates,
  946. + notify_insert_handler, notify_delete_handler, monitor_path=None):
  947. + """
  948. + Install a monitor in the Zeitgeist engine that calls back
  949. + when events matching *event_templates* are logged. The matching
  950. + is done exactly as in the *find_** family of methods and in
  951. + :meth:`Event.matches_template <zeitgeist.datamodel.Event.matches_template>`.
  952. + Furthermore matched events must also have timestamps lying in
  953. + *time_range*.
  954. +
  955. + To remove a monitor call :meth:`remove_monitor` on the returned
  956. + :class:`Monitor` instance.
  957. +
  958. + The *notify_insert_handler* will be called when events matching
  959. + the monitor are inserted into the log. The *notify_delete_handler*
  960. + function will be called when events lying within the monitored
  961. + time range are deleted.
  962. +
  963. + :param time_range: A :class:`TimeRange <zeitgeist.datamodel.TimeRange>`
  964. + that matched events must lie within. To obtain a time range
  965. + from now and indefinitely into the future use
  966. + :meth:`TimeRange.from_now() <zeitgeist.datamodel.TimeRange.from_now>`
  967. + :param event_templates: The event templates to look for
  968. + :param notify_insert_handler: Callback for receiving notifications
  969. + about insertions of matching events. The callback should take
  970. + a :class:`TimeRange` as first parameter and a list of
  971. + :class:`Events` as the second parameter.
  972. + The time range will cover the minimum and maximum timestamps
  973. + of the inserted events
  974. + :param notify_delete_handler: Callback for receiving notifications
  975. + about deletions of events in the monitored time range.
  976. + The callback should take a :class:`TimeRange` as first
  977. + parameter and a list of event ids as the second parameter.
  978. + Note that an event id is simply an unsigned integer.
  979. + :param monitor_path: Optional argument specifying the DBus path
  980. + to install the client side monitor object on. If none is provided
  981. + the client will provide one for you namespaced under
  982. + /org/gnome/zeitgeist/monitor/*
  983. + :returns: a :class:`Monitor`
  984. + """
  985. + self._check_list_or_tuple(event_templates)
  986. + self._check_members(event_templates, Event)
  987. + if not callable(notify_insert_handler):
  988. + raise TypeError("notify_insert_handler not callable, found %s" % \
  989. + notify_reply_handler)
  990. +
  991. + if not callable(notify_delete_handler):
  992. + raise TypeError("notify_delete_handler not callable, found %s" % \
  993. + notify_reply_handler)
  994. +
  995. +
  996. + mon = Monitor(time_range, event_templates, notify_insert_handler,
  997. + notify_delete_handler, monitor_path=monitor_path,
  998. + event_type=self._event_type)
  999. + self._iface.InstallMonitor(mon.path,
  1000. + mon.time_range,
  1001. + mon.templates,
  1002. + reply_handler=self._void_reply_handler,
  1003. + error_handler=lambda err: log.warn(
  1004. + "Error installing monitor: %s" % err))
  1005. + self._installed_monitors.append(mon)
  1006. + return mon
  1007. +
  1008. + def remove_monitor (self, monitor, monitor_removed_handler=None):
  1009. + """
  1010. + Remove a :class:`Monitor` installed with :meth:`install_monitor`
  1011. +
  1012. + :param monitor: Monitor to remove. Either as a :class:`Monitor`
  1013. + instance or a DBus object path to the monitor either as a
  1014. + string or :class:`dbus.ObjectPath`
  1015. + :param monitor_removed_handler: A callback function taking
  1016. + one integer argument. 1 on success, 0 on failure.
  1017. + """
  1018. + if isinstance(monitor, str):
  1019. + path = dbus.ObjectPath(monitor)
  1020. + elif isinstance(monitor, Monitor):
  1021. + path = monitor.path
  1022. + else:
  1023. + raise TypeError(
  1024. + "Monitor, str, or unicode expected. Found %s" % type(monitor))
  1025. +
  1026. + if callable(monitor_removed_handler):
  1027. +
  1028. + def dispatch_handler (error=None):
  1029. + if error :
  1030. + log.warn("Error removing monitor %s: %s" % (monitor, error))
  1031. + monitor_removed_handler(0)
  1032. + else: monitor_removed_handler(1)
  1033. +
  1034. + reply_handler = dispatch_handler
  1035. + error_handler = dispatch_handler
  1036. + else:
  1037. + reply_handler = self._void_reply_handler
  1038. + error_handler = lambda err: log.warn(
  1039. + "Error removing monitor %s: %s" % (monitor, err))
  1040. +
  1041. + self._iface.RemoveMonitor(path,
  1042. + reply_handler=reply_handler,
  1043. + error_handler=error_handler)
  1044. + self._installed_monitors.remove(monitor)
  1045. +
  1046. + # Data-source related class variables
  1047. + _data_sources = {}
  1048. + _data_sources_callback_installed = False
  1049. +
  1050. + def register_data_source(self, unique_id, name, description,
  1051. + event_templates, enabled_callback=None):
  1052. + """
  1053. + Register a data-source as currently running. If the data-source was
  1054. + already in the database, its metadata (name, description and
  1055. + event_templates) are updated.
  1056. +
  1057. + If the data-source registry isn't enabled, do nothing.
  1058. +
  1059. + The optional event_templates is purely informational and serves to
  1060. + let data-source management applications and other data-sources know
  1061. + what sort of information you log.
  1062. +
  1063. + :param unique_id: unique ASCII string identifying the data-source
  1064. + :param name: data-source name (may be translated)
  1065. + :param description: data-source description (may be translated)
  1066. + :param event_templates: list of
  1067. + :class:`Event <zeitgeist.datamodel.Event>` templates.
  1068. + :param enabled_callback: method to call as response with the `enabled'
  1069. + status of the data-source, and after that every time said status
  1070. + is toggled. See set_data_source_enabled_callback() for more
  1071. + information.
  1072. + """
  1073. +
  1074. + self._data_sources[unique_id] = {'enabled': None, 'callback': None}
  1075. +
  1076. + if enabled_callback is not None:
  1077. + self.set_data_source_enabled_callback(unique_id, enabled_callback)
  1078. +
  1079. + def _data_source_enabled_cb(unique_id, enabled):
  1080. + if unique_id not in self._data_sources:
  1081. + return
  1082. + self._data_sources[unique_id]['enabled'] = enabled
  1083. + callback = self._data_sources[unique_id]['callback']
  1084. + if callback is not None:
  1085. + callback(enabled)
  1086. +
  1087. + def _data_source_register_cb(enabled):
  1088. + _data_source_enabled_cb(unique_id, enabled)
  1089. +
  1090. + if not self._data_sources_callback_installed:
  1091. + self._registry.connect('DataSourceEnabled', _data_source_enabled_cb)
  1092. + self._data_sources_callback_installed = True
  1093. +
  1094. + self._registry.RegisterDataSource(unique_id, name, description,
  1095. + event_templates,
  1096. + reply_handler=_data_source_register_cb,
  1097. + error_handler=self._void_reply_handler) # Errors are ignored
  1098. +
  1099. + def set_data_source_enabled_callback(self, unique_id, enabled_callback):
  1100. + """
  1101. + This method may only be used after having registered the given unique_id
  1102. + with register_data_source before.
  1103. +
  1104. + It registers a method to be called whenever the `enabled' status of
  1105. + the previously registered data-source changes.
  1106. +
  1107. + Remember that on some systems the DataSourceRegistry extension may be
  1108. + disabled, in which case this method will have no effect.
  1109. + """
  1110. +
  1111. + if unique_id not in self._data_sources:
  1112. + raise ValueError('set_data_source_enabled_callback() called before ' \
  1113. + 'register_data_source()')
  1114. +
  1115. + if not callable(enabled_callback):
  1116. + raise TypeError('enabled_callback: expected a callable method')
  1117. +
  1118. + self._data_sources[unique_id]['callback'] = enabled_callback
  1119. +
  1120. + def _check_list_or_tuple(self, collection):
  1121. + """
  1122. + Raise a ValueError unless 'collection' is a list or tuple
  1123. + """
  1124. + if not (isinstance(collection, list) or isinstance(collection, tuple)):
  1125. + raise TypeError("Expected list or tuple, found %s" % type(collection))
  1126. +
  1127. + def _check_members (self, collection, member_class):
  1128. + """
  1129. + Raise a ValueError unless all of the members of 'collection'
  1130. + are of class 'member_class'
  1131. + """
  1132. + for m in collection:
  1133. + if not isinstance(m, member_class):
  1134. + raise TypeError(
  1135. + "Collection contains member of invalid type %s. Expected %s" % \
  1136. + (m.__class__, member_class))
  1137. +
  1138. + def _void_reply_handler(self, *args, **kwargs):
  1139. + """
  1140. + Reply handler for async DBus calls that simply ignores the response
  1141. + """
  1142. + pass
  1143. +
  1144. + def _stderr_error_handler(self, exception, normal_reply_handler=None,
  1145. + normal_reply_data=None):
  1146. + """
  1147. + Error handler for async DBus calls that prints the error
  1148. + to sys.stderr
  1149. + """
  1150. + print("Error from Zeitgeist engine:", exception, file=sys.stderr)
  1151. +
  1152. + if callable(normal_reply_handler):
  1153. + normal_reply_handler(normal_reply_data)
  1154. +
  1155. +_FIND_EVENTS_FOR_TEMPLATES_ARGS = inspect.getargspec(
  1156. + ZeitgeistClient.find_events_for_templates)[0]
  1157. +
  1158. +# vim:noexpandtab:ts=4:sw=4
  1159. diff -Naur zeitgeist-explorer-0.2.orig/zgexplorer/datamodel.py zeitgeist-explorer-0.2/zgexplorer/datamodel.py
  1160. --- zeitgeist-explorer-0.2.orig/zgexplorer/datamodel.py 1970-01-01 00:00:00.000000000 +0000
  1161. +++ zeitgeist-explorer-0.2/zgexplorer/datamodel.py 2019-03-31 13:36:50.762866483 +0000
  1162. @@ -0,0 +1,1210 @@
  1163. +# -.- coding: utf-8 -.-
  1164. +
  1165. +# Zeitgeist
  1166. +#
  1167. +# Copyright © 2009 Mikkel Kamstrup Erlandsen <mikkel.kamstrup@gmail.com>
  1168. +# Copyright © 2009 Markus Korn <thekorn@gmx.de>
  1169. +# Copyright © 2009-2010 Seif Lotfy <seif@lotfy.com>
  1170. +# Copyright © 2009-2010 Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
  1171. +# Copyright © 2011 Collabora Ltd.
  1172. +# By Siegfried-Angel Gevatter Pujals <rainct@ubuntu.com>
  1173. +#
  1174. +# This program is free software: you can redistribute it and/or modify
  1175. +# it under the terms of the GNU Lesser General Public License as published by
  1176. +# the Free Software Foundation, either version 2.1 of the License, or
  1177. +# (at your option) any later version.
  1178. +#
  1179. +# This program is distributed in the hope that it will be useful,
  1180. +# but WITHOUT ANY WARRANTY; without even the implied warranty of
  1181. +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1182. +# GNU Lesser General Public License for more details.
  1183. +#
  1184. +# You should have received a copy of the GNU Lesser General Public License
  1185. +# along with this program. If not, see <http://www.gnu.org/licenses/>.
  1186. +
  1187. +import os.path
  1188. +import gettext
  1189. +import time
  1190. +import sys
  1191. +gettext.install("zeitgeist")
  1192. +
  1193. +__all__ = [
  1194. + 'Interpretation',
  1195. + 'Manifestation',
  1196. + 'ResultType',
  1197. + 'RelevantResultType',
  1198. + 'StorageState',
  1199. + 'TimeRange',
  1200. + 'DataSource',
  1201. + 'Event',
  1202. + 'Subject',
  1203. + 'NULL_EVENT',
  1204. + 'NEGATION_OPERATOR',
  1205. +]
  1206. +
  1207. +NEGATION_OPERATOR = "!"
  1208. +WILDCARD = "*"
  1209. +
  1210. +def EQUAL(x, y):
  1211. + """checks if both given arguments are equal"""
  1212. + return x == y
  1213. +
  1214. +def STARTSWITH(x, y):
  1215. + """checks if 'x' startswith 'y'"""
  1216. + return x.startswith(y)
  1217. +
  1218. +NEEDS_CHILD_RESOLUTION = set()
  1219. +
  1220. +def get_timestamp_for_now():
  1221. + """
  1222. + Return the current time in milliseconds since the Unix Epoch.
  1223. + """
  1224. + return int(time.time() * 1000)
  1225. +
  1226. +class EnumValue(int):
  1227. + """Class which behaves like an int, but has an additional docstring"""
  1228. +
  1229. + def __new__(cls, value, doc=""):
  1230. + obj = super(EnumValue, cls).__new__(EnumValue, value)
  1231. + obj.__doc__ = "%s. ``(Integer value: %i)``" %(doc, obj)
  1232. + return obj
  1233. +
  1234. +def isCamelCase(text):
  1235. + return text and text[0].isupper() and " " not in text
  1236. +
  1237. +def get_name_or_str(obj):
  1238. + try:
  1239. + return str(obj.name)
  1240. + except AttributeError:
  1241. + return str(obj)
  1242. +
  1243. +_SYMBOLS_BY_URI = {}
  1244. +
  1245. +class Symbol(str):
  1246. +
  1247. + def __new__(cls, name, parent=None, uri=None, display_name=None, doc=None, auto_resolve=True):
  1248. + if not isCamelCase(name):
  1249. + raise ValueError("Naming convention requires symbol name to be CamelCase, got '%s'" %name)
  1250. + return super(Symbol, cls).__new__(Symbol, uri or name)
  1251. +
  1252. + def __init__(self, name, parent=None, uri=None, display_name=None, doc=None, auto_resolve=True):
  1253. + self._children = dict()
  1254. + self._all_children = None
  1255. + self._parents = parent or set() # will be bootstrapped to a dict at module load time
  1256. + assert isinstance(self._parents, set), name
  1257. + self._name = name
  1258. + self._uri = uri
  1259. + self._display_name = display_name
  1260. + self._doc = doc
  1261. + _SYMBOLS_BY_URI[uri] = self
  1262. +
  1263. + def __repr__(self):
  1264. + return "<%s '%s'>" %(get_name_or_str(self), self.uri)
  1265. +
  1266. + def __getattr__(self, name):
  1267. + self._ensure_all_children()
  1268. + try:
  1269. + return self._all_children[name]
  1270. + except KeyError:
  1271. + for child in self.iter_all_children():
  1272. + if child == self:
  1273. + continue
  1274. + try:
  1275. + return getattr(child, name)
  1276. + except AttributeError:
  1277. + pass
  1278. + raise AttributeError("'%s' object has no attribute '%s'" %(self.__class__.__name__, name))
  1279. +
  1280. + def __getitem__ (self, uri):
  1281. + return _SYMBOLS_BY_URI[uri]
  1282. +
  1283. + def _ensure_all_children (self):
  1284. + if self._all_children is not None : return
  1285. + self._all_children = dict()
  1286. + for child in self._children.values():
  1287. + child._visit(self._all_children)
  1288. +
  1289. + def _visit (self, dikt):
  1290. + dikt[self.name] = self
  1291. + for child in self._children.values():
  1292. + child._visit(dikt)
  1293. +
  1294. + @staticmethod
  1295. + def find_child_uris_extended (uri):
  1296. + """
  1297. + Creates a list of all known child Symbols of `uri`, including
  1298. + `uri` itself in the list. Hence the "extended". If `uri`
  1299. + is unknown a list containing only `uri` is returned.
  1300. + """
  1301. + try:
  1302. + symbol = _SYMBOLS_BY_URI[uri]
  1303. + children = list(symbol.get_all_children())
  1304. + children.append(uri)
  1305. + return children
  1306. + except KeyError as e:
  1307. + return [uri]
  1308. +
  1309. +
  1310. + @property
  1311. + def uri(self):
  1312. + return self._uri or self.name
  1313. +
  1314. + @property
  1315. + def display_name(self):
  1316. + return self._display_name or ""
  1317. +
  1318. + @property
  1319. + def name(self):
  1320. + return self._name
  1321. + __name__ = name
  1322. +
  1323. + def __dir__(self):
  1324. + self._ensure_all_children()
  1325. + return list(self._all_children.keys())
  1326. +
  1327. + @property
  1328. + def doc(self):
  1329. + return self._doc or ""
  1330. +
  1331. + @property
  1332. + def __doc__(self):
  1333. + return "%s\n\n %s. ``(Display name: '%s')``" %(self.uri, self.doc.rstrip("."), self.display_name)
  1334. +
  1335. + def get_children(self):
  1336. + """
  1337. + Returns a list of immediate child symbols
  1338. + """
  1339. + return frozenset(iter(self._children.values()))
  1340. +
  1341. + def iter_all_children(self):
  1342. + """
  1343. + Returns a generator that recursively iterates over all children
  1344. + of this symbol
  1345. + """
  1346. + self._ensure_all_children()
  1347. + return iter(self._all_children.values())
  1348. +
  1349. + def get_all_children(self):
  1350. + """
  1351. + Return a read-only set containing all children of this symbol
  1352. + """
  1353. + return frozenset(self.iter_all_children())
  1354. +
  1355. + def get_parents(self):
  1356. + """
  1357. + Returns a list of immediate parent symbols
  1358. + """
  1359. + return frozenset(iter(self._parents.values()))
  1360. +
  1361. + def is_child_of (self, parent):
  1362. + """
  1363. + Returns True if this symbol is a child of `parent`.
  1364. + """
  1365. + if not isinstance (parent, Symbol):
  1366. + try:
  1367. + parent = _SYMBOLS_BY_URI[parent]
  1368. + except KeyError as e:
  1369. + # Parent is not a known URI
  1370. + return self.uri == parent
  1371. +
  1372. + # Invariant: parent is a Symbol
  1373. + if self.uri == parent.uri : return True
  1374. +
  1375. + parent._ensure_all_children()
  1376. +
  1377. + # FIXME: We should really check that child.uri is in there,
  1378. + # but that is not fast with the current code layout
  1379. + return self.name in parent._all_children
  1380. +
  1381. + @staticmethod
  1382. + def uri_is_child_of (child, parent):
  1383. + """
  1384. + Returns True if `child` is a child of `parent`. Both `child`
  1385. + and `parent` arguments must be any combination of
  1386. + :class:`Symbol` and/or string.
  1387. + """
  1388. + if isinstance (child, str):
  1389. + try:
  1390. + child = _SYMBOLS_BY_URI[child]
  1391. + except KeyError as e:
  1392. + # Child is not a know URI
  1393. + if isinstance (parent, str):
  1394. + return child == parent
  1395. + elif isinstance (parent, Symbol):
  1396. + return child == parent.uri
  1397. + else:
  1398. + return False
  1399. +
  1400. + if not isinstance (child, Symbol):
  1401. + raise ValueError("Child argument must be a Symbol or string. Got %s" % type(child))
  1402. +
  1403. + return child.is_child_of(parent)
  1404. +
  1405. +class TimeRange(list):
  1406. + """
  1407. + A class that represents a time range with a beginning and an end.
  1408. + The timestamps used are integers representing milliseconds since the
  1409. + Epoch.
  1410. +
  1411. + By design this class will be automatically transformed to the DBus
  1412. + type (xx).
  1413. + """
  1414. + # Maximal value of our timestamps
  1415. + _max_stamp = 2**63 - 1
  1416. +
  1417. + def __init__ (self, begin, end):
  1418. + super(TimeRange, self).__init__((int(begin), int(end)))
  1419. +
  1420. + def __eq__ (self, other):
  1421. + return self.begin == other.begin and self.end == other.end
  1422. +
  1423. + def __str__ (self):
  1424. + return "(%s, %s)" % (self.begin, self.end)
  1425. +
  1426. + def get_begin(self):
  1427. + return self[0]
  1428. +
  1429. + def set_begin(self, begin):
  1430. + self[0] = begin
  1431. + begin = property(get_begin, set_begin,
  1432. + doc="The begining timestamp of this time range")
  1433. +
  1434. + def get_end(self):
  1435. + return self[1]
  1436. +
  1437. + def set_end(self, end):
  1438. + self[1] = end
  1439. + end = property(get_end, set_end,
  1440. + doc="The end timestamp of this time range")
  1441. +
  1442. + @classmethod
  1443. + def until_now(cls):
  1444. + """
  1445. + Return a :class:`TimeRange` from 0 to the instant of invocation
  1446. + """
  1447. + return cls(0, int(time.time() * 1000))
  1448. +
  1449. + @classmethod
  1450. + def from_now(cls):
  1451. + """
  1452. + Return a :class:`TimeRange` from the instant of invocation to
  1453. + the end of time
  1454. + """
  1455. + return cls(int(time.time() * 1000), cls._max_stamp)
  1456. +
  1457. + @classmethod
  1458. + def from_seconds_ago(cls, sec):
  1459. + """
  1460. + Return a :class:`TimeRange` ranging from "sec" seconds before
  1461. + the instant of invocation to the same.
  1462. + """
  1463. + now = int(time.time() * 1000)
  1464. + return cls(now - (sec * 1000), now)
  1465. +
  1466. + @classmethod
  1467. + def from_timestamp(cls, timestamp):
  1468. + """
  1469. + Return a :class:`TimeRange` ranging from the given timestamp until
  1470. + the end of time.
  1471. +
  1472. + The given timestamp is expected to be expressed in miliseconds.
  1473. + """
  1474. + return cls(int(timestamp), cls._max_stamp)
  1475. +
  1476. + @classmethod
  1477. + def always(cls):
  1478. + """
  1479. + Return a :class:`TimeRange` from 0 (January 1, 1970) to the most
  1480. + distant future
  1481. + """
  1482. + return cls(0, cls._max_stamp)
  1483. +
  1484. + def is_always(self):
  1485. + """
  1486. + Returns True if this time range goes from timestamp 0 (January 1, 1970)
  1487. + -or lower- to the most distant future.
  1488. + """
  1489. + return self.begin <= 0 and self.end >= TimeRange._max_stamp
  1490. +
  1491. + def intersect(self, time_range):
  1492. + """
  1493. + Return a new :class:`TimeRange` that is the intersection of the
  1494. + two time range intervals. If the intersection is empty this
  1495. + method returns :const:`None`.
  1496. + """
  1497. + # Behold the boolean madness!
  1498. + result = TimeRange(0,0)
  1499. + if self.begin < time_range.begin:
  1500. + if self.end < time_range.begin:
  1501. + return None
  1502. + else:
  1503. + result.begin = time_range.begin
  1504. + else:
  1505. + if self.begin > time_range.end:
  1506. + return None
  1507. + else:
  1508. + result.begin = self.begin
  1509. +
  1510. + if self.end < time_range.end:
  1511. + if self.end < time_range.begin:
  1512. + return None
  1513. + else:
  1514. + result.end = self.end
  1515. + else:
  1516. + if self.begin > time_range.end:
  1517. + return None
  1518. + else:
  1519. + result.end = time_range.end
  1520. +
  1521. + return result
  1522. +
  1523. +
  1524. +class Subject(list):
  1525. + """
  1526. + Represents a subject of an :class:`Event`. This class is both used to
  1527. + represent actual subjects, but also create subject templates to match
  1528. + other subjects against.
  1529. +
  1530. + Applications should normally use the method :meth:`new_for_values` to
  1531. + create new subjects.
  1532. + """
  1533. + Fields = (Uri,
  1534. + Interpretation,
  1535. + Manifestation,
  1536. + Origin,
  1537. + Mimetype,
  1538. + Text,
  1539. + Storage,
  1540. + CurrentUri,
  1541. + CurrentOrigin) = list(range(9))
  1542. +
  1543. + SUPPORTS_NEGATION = (Uri, CurrentUri, Interpretation, Manifestation,
  1544. + Origin, CurrentOrigin, Mimetype)
  1545. + SUPPORTS_WILDCARDS = (Uri, CurrentUri, Origin, CurrentOrigin, Mimetype)
  1546. +
  1547. + def __init__(self, data=None):
  1548. + if data:
  1549. + if len(data) == len(Subject.Fields) - 2:
  1550. + # current_uri has been added in Zeitgeist 0.8.0
  1551. + data.append("")
  1552. + if len(data) == len(Subject.Fields) - 1:
  1553. + # current_origin has been added in Zeitgeist 1.0 Beta 1
  1554. + data.append("")
  1555. + if len(data) < len(Subject.Fields):
  1556. + raise ValueError(
  1557. + "Invalid subject data length %s, expected %s" \
  1558. + %(len(data), len(Subject.Fields)))
  1559. + super(Subject, self).__init__(data)
  1560. + else:
  1561. + super(Subject, self).__init__([""]*len(Subject.Fields))
  1562. +
  1563. + def __repr__(self):
  1564. + return "%s(%s)" %(
  1565. + self.__class__.__name__, super(Subject, self).__repr__()
  1566. + )
  1567. +
  1568. + def __eq__(self, other):
  1569. + for field in Subject.Fields:
  1570. + if field in (Subject.CurrentUri, Subject.CurrentOrigin) and \
  1571. + not self[field] or not other[field]:
  1572. + continue
  1573. + if self[field] != other[field]:
  1574. + return False
  1575. + return True
  1576. +
  1577. + @staticmethod
  1578. + def new_for_values (**values):
  1579. + """
  1580. + Create a new Subject instance and set its properties according
  1581. + to the keyword arguments passed to this method.
  1582. +
  1583. + :param uri: The URI of the subject. Eg. *file:///tmp/ratpie.txt*
  1584. + :param current_uri: The current known URI of the subject (if it was moved or deleted).
  1585. + :param interpretation: The interpretation type of the subject, given either as a string URI or as a :class:`Interpretation` instance
  1586. + :param manifestation: The manifestation type of the subject, given either as a string URI or as a :class:`Manifestation` instance
  1587. + :param origin: The URI of the location where subject resides or can be found
  1588. + :param current_origin: The URI of the location where subject resides or can be found (if it was moved or deleted).
  1589. + :param mimetype: The mimetype of the subject encoded as a string, if applicable. Eg. *text/plain*.
  1590. + :param text: Free form textual annotation of the subject.
  1591. + :param storage: String identifier for the storage medium of the subject. This should be the UUID of the volume or the string "net" for resources requiring a network interface, and the string "deleted" for subjects that are deleted.
  1592. + """
  1593. + self = Subject()
  1594. + for key, value in values.items():
  1595. + if not key in ("uri", "current_uri", "interpretation",
  1596. + "manifestation", "origin", "current_origin",
  1597. + "mimetype", "text", "storage"):
  1598. + raise ValueError("Subject parameter '%s' is not supported" %key)
  1599. + setattr(self, key, value)
  1600. + return self
  1601. +
  1602. + def get_uri(self):
  1603. + return self[Subject.Uri]
  1604. +
  1605. + def set_uri(self, value):
  1606. + self[Subject.Uri] = value
  1607. + uri = property(get_uri, set_uri,
  1608. + doc="Read/write property with the URI of the subject encoded as a string")
  1609. +
  1610. + def get_current_uri(self):
  1611. + return self[Subject.CurrentUri]
  1612. +
  1613. + def set_current_uri(self, value):
  1614. + self[Subject.CurrentUri] = value
  1615. + current_uri = property(get_current_uri, set_current_uri,
  1616. + doc="Read/write property with the current URI of the subject encoded as a string")
  1617. +
  1618. + def get_interpretation(self):
  1619. + return self[Subject.Interpretation]
  1620. +
  1621. + def set_interpretation(self, value):
  1622. + self[Subject.Interpretation] = value
  1623. + interpretation = property(get_interpretation, set_interpretation,
  1624. + doc="Read/write property defining the :class:`interpretation type <Interpretation>` of the subject")
  1625. +
  1626. + def get_manifestation(self):
  1627. + return self[Subject.Manifestation]
  1628. +
  1629. + def set_manifestation(self, value):
  1630. + self[Subject.Manifestation] = value
  1631. + manifestation = property(get_manifestation, set_manifestation,
  1632. + doc="Read/write property defining the :class:`manifestation type <Manifestation>` of the subject")
  1633. +
  1634. + def get_origin(self):
  1635. + return self[Subject.Origin]
  1636. +
  1637. + def set_origin(self, value):
  1638. + self[Subject.Origin] = value
  1639. + origin = property(get_origin, set_origin,
  1640. + doc="Read/write property with the URI of the location where the subject can be found. For files this is the parent directory, or for downloaded files it would be the URL of the page where you clicked the download link")
  1641. +
  1642. + def get_current_origin(self):
  1643. + return self[Subject.CurrentOrigin]
  1644. +
  1645. + def set_current_origin(self, value):
  1646. + self[Subject.CurrentOrigin] = value
  1647. + current_origin = property(get_current_origin, set_current_origin,
  1648. + doc="Read/write property with the URI of the location where the subject can be found. For files this is the parent directory, or for downloaded files it would be the URL of the page where you clicked the download link")
  1649. +
  1650. + def get_mimetype(self):
  1651. + return self[Subject.Mimetype]
  1652. +
  1653. + def set_mimetype(self, value):
  1654. + self[Subject.Mimetype] = value
  1655. + mimetype = property(get_mimetype, set_mimetype,
  1656. + doc="Read/write property containing the mimetype of the subject (encoded as a string) if applicable")
  1657. +
  1658. + def get_text(self):
  1659. + return self[Subject.Text]
  1660. +
  1661. + def set_text(self, value):
  1662. + self[Subject.Text] = value
  1663. + text = property(get_text, set_text,
  1664. + doc="Read/write property with a free form textual annotation of the subject")
  1665. +
  1666. + def get_storage(self):
  1667. + return self[Subject.Storage]
  1668. +
  1669. + def set_storage(self, value):
  1670. + self[Subject.Storage] = value
  1671. + storage = property(get_storage, set_storage,
  1672. + doc="Read/write property with a string id of the storage medium where the subject is stored. Fx. the UUID of the disk partition or just the string 'net' for items requiring network interface to be available")
  1673. +
  1674. + def matches_template (self, subject_template):
  1675. + """
  1676. + Return True if this Subject matches *subject_template*. Empty
  1677. + fields in the template are treated as wildcards.
  1678. + Interpretations and manifestations are also matched if they are
  1679. + children of the types specified in `subject_template`.
  1680. +
  1681. + See also :meth:`Event.matches_template`
  1682. + """
  1683. + for m in Subject.Fields:
  1684. + if not subject_template[m]:
  1685. + # empty fields are handled as wildcards
  1686. + continue
  1687. + if m == Subject.Storage:
  1688. + # we do not support searching by storage field for now
  1689. + # see LP: #580364
  1690. + raise ValueError("zeitgeist does not support searching by 'storage' field")
  1691. + elif m in (Subject.Interpretation, Subject.Manifestation):
  1692. + # symbols are treated differently
  1693. + comp = Symbol.uri_is_child_of
  1694. + else:
  1695. + comp = EQUAL
  1696. + if not self._check_field_match(m, subject_template[m], comp):
  1697. + return False
  1698. + return True
  1699. +
  1700. + def _check_field_match(self, field_id, expression, comp):
  1701. + """ Checks if an expression matches a field given by its `field_id`
  1702. + using a `comp` comparison function """
  1703. + if field_id in self.SUPPORTS_NEGATION \
  1704. + and expression.startswith(NEGATION_OPERATOR):
  1705. + return not self._check_field_match(field_id, expression[len(NEGATION_OPERATOR):], comp)
  1706. + elif field_id in self.SUPPORTS_WILDCARDS \
  1707. + and expression.endswith(WILDCARD):
  1708. + assert comp == EQUAL, "wildcards only work for pure text fields"
  1709. + return self._check_field_match(field_id, expression[:-len(WILDCARD)], STARTSWITH)
  1710. + else:
  1711. + return comp(self[field_id], expression)
  1712. +
  1713. +class Event(list):
  1714. + """
  1715. + Core data structure in the Zeitgeist framework. It is an optimized and
  1716. + convenient representation of an event.
  1717. +
  1718. + This class is designed so that you can pass it directly over
  1719. + DBus using the Python DBus bindings. It will automagically be
  1720. + marshalled with the signature a(asaasay). See also the section
  1721. + on the :ref:`event serialization format <event_serialization_format>`.
  1722. +
  1723. + This class does integer based lookups everywhere and can wrap any
  1724. + conformant data structure without the need for marshalling back and
  1725. + forth between DBus wire format. These two properties makes it highly
  1726. + efficient and is recommended for use everywhere.
  1727. + """
  1728. + Fields = (Id,
  1729. + Timestamp,
  1730. + Interpretation,
  1731. + Manifestation,
  1732. + Actor,
  1733. + Origin) = list(range(6))
  1734. +
  1735. + SUPPORTS_NEGATION = (Interpretation, Manifestation, Actor, Origin)
  1736. + SUPPORTS_WILDCARDS = (Actor, Origin)
  1737. +
  1738. + _subject_type = Subject
  1739. +
  1740. + def __init__(self, struct = None):
  1741. + """
  1742. + If 'struct' is set it must be a list containing the event
  1743. + metadata in the first position, and optionally the list of
  1744. + subjects in the second position, and again optionally the event
  1745. + payload in the third position.
  1746. +
  1747. + Unless the event metadata contains a timestamp the event will
  1748. + have its timestamp set to "now". Ie. the instant of invocation.
  1749. +
  1750. + The event metadata (struct[0]) will be used as is, and must
  1751. + contain the event data on the positions defined by the
  1752. + Event.Fields enumeration.
  1753. +
  1754. + Likewise each member of the subjects (struct[1]) must be an
  1755. + array with subject metadata defined in the positions as laid
  1756. + out by the Subject.Fields enumeration.
  1757. +
  1758. + On the third position (struct[2]) the struct may contain the
  1759. + event payload, which can be an arbitrary binary blob. The payload
  1760. + will be transfered over DBus with the 'ay' signature (as an
  1761. + array of bytes).
  1762. + """
  1763. + super(Event, self).__init__()
  1764. + if struct:
  1765. + if len(struct) == 1:
  1766. + self.append(self._check_event_struct(struct[0]))
  1767. + self.append([])
  1768. + self.append("")
  1769. + elif len(struct) == 2:
  1770. + self.append(self._check_event_struct(struct[0]))
  1771. + self.append(list(map(self._subject_type, struct[1])))
  1772. + self.append("")
  1773. + elif len(struct) == 3:
  1774. + self.append(self._check_event_struct(struct[0]))
  1775. + self.append(list(map(self._subject_type, struct[1])))
  1776. + self.append(struct[2])
  1777. + else:
  1778. + raise ValueError("Invalid struct length %s" % len(struct))
  1779. + # If this event is being created from an existing Event instance,
  1780. + # make a copy of the list holding the event information. This
  1781. + # enables the idiom "event2 = Event(event1)" to copy an event.
  1782. + if isinstance(struct, Event):
  1783. + self[0] = list(self[0])
  1784. + else:
  1785. + self.extend(([""]* len(Event.Fields), [], ""))
  1786. +
  1787. + # If we have no timestamp just set it to now
  1788. + if not self[0][Event.Timestamp]:
  1789. + self[0][Event.Timestamp] = str(get_timestamp_for_now())
  1790. + # If we have no origin for Event then we set None
  1791. + if len(self[0]) == 5:
  1792. + self[0].append(None)
  1793. +
  1794. + @classmethod
  1795. + def _check_event_struct(cls, event_data):
  1796. + if len(event_data) == len(cls.Fields) - 1:
  1797. + # Old versions of Zeitgeist didn't have the event origin field.
  1798. + event_data.append("")
  1799. + if len(event_data) < len(cls.Fields):
  1800. + raise ValueError("event_data must have %s members, found %s" % \
  1801. + (len(cls.Fields), len(event_data)))
  1802. + return event_data
  1803. +
  1804. + @classmethod
  1805. + def new_for_data(cls, event_data):
  1806. + """
  1807. + Create a new Event setting event_data as the backing array
  1808. + behind the event metadata. The contents of the array must
  1809. + contain the event metadata at the positions defined by the
  1810. + Event.Fields enumeration.
  1811. + """
  1812. + self = cls()
  1813. + self[0] = self._check_event_struct(event_data)
  1814. + return self
  1815. +
  1816. + @classmethod
  1817. + def new_for_struct(cls, struct):
  1818. + """Returns a new Event instance or None if `struct` is a `NULL_EVENT`"""
  1819. + if struct == NULL_EVENT:
  1820. + return None
  1821. + return cls(struct)
  1822. +
  1823. + @classmethod
  1824. + def new_for_values(cls, **values):
  1825. + """
  1826. + Create a new Event instance from a collection of keyword
  1827. + arguments.
  1828. +
  1829. +
  1830. + :param timestamp: Event timestamp in milliseconds since the Unix Epoch
  1831. + :param interpretaion: The Interpretation type of the event
  1832. + :param manifestation: Manifestation type of the event
  1833. + :param actor: The actor (application) that triggered the event
  1834. + :param origin: The origin (domain) where the event was triggered
  1835. + :param subjects: A list of :class:`Subject` instances
  1836. +
  1837. + Instead of setting the *subjects* argument one may use a more
  1838. + convenient approach for events that have exactly one Subject.
  1839. + Namely by using the *subject_** keys - mapping directly to their
  1840. + counterparts in :meth:`Subject.new_for_values`:
  1841. +
  1842. + :param subject_uri:
  1843. + :param subject_current_uri:
  1844. + :param subject_interpretation:
  1845. + :param subject_manifestation:
  1846. + :param subject_origin:
  1847. + :param subject_current_origin:
  1848. + :param subject_mimetype:
  1849. + :param subject_text:
  1850. + :param subject_storage:
  1851. + """
  1852. + self = cls()
  1853. + for key in values:
  1854. + if not key in ("timestamp", "interpretation", "manifestation",
  1855. + "actor", "origin", "subjects", "subject_uri",
  1856. + "subject_current_uri", "subject_interpretation",
  1857. + "subject_manifestation", "subject_origin",
  1858. + "subject_current_origin", "subject_mimetype", "subject_text",
  1859. + "subject_storage"):
  1860. + raise ValueError("Event parameter '%s' is not supported" % key)
  1861. +
  1862. + self.timestamp = values.get("timestamp", self.timestamp)
  1863. + self.interpretation = values.get("interpretation", "")
  1864. + self.manifestation = values.get("manifestation", "")
  1865. + self.actor = values.get("actor", "")
  1866. + self.origin = values.get("origin", "")
  1867. + self.subjects = values.get("subjects", self.subjects)
  1868. +
  1869. + if self._dict_contains_subject_keys(values):
  1870. + if "subjects" in values:
  1871. + raise ValueError("Subject keys, subject_*, specified together with full subject list")
  1872. + subj = self._subject_type()
  1873. + subj.uri = values.get("subject_uri", "")
  1874. + subj.current_uri = values.get("subject_current_uri", "")
  1875. + subj.interpretation = values.get("subject_interpretation", "")
  1876. + subj.manifestation = values.get("subject_manifestation", "")
  1877. + subj.origin = values.get("subject_origin", "")
  1878. + subj.current_origin = values.get("subject_current_origin", "")
  1879. + subj.mimetype = values.get("subject_mimetype", "")
  1880. + subj.text = values.get("subject_text", "")
  1881. + subj.storage = values.get("subject_storage", "")
  1882. + self.subjects = [subj]
  1883. +
  1884. + return self
  1885. +
  1886. + @staticmethod
  1887. + def _dict_contains_subject_keys (dikt):
  1888. + if "subject_uri" in dikt: return True
  1889. + elif "subject_current_uri" in dikt: return True
  1890. + elif "subject_current_origin" in dikt: return True
  1891. + elif "subject_interpretation" in dikt: return True
  1892. + elif "subject_manifestation" in dikt: return True
  1893. + elif "subject_origin" in dikt: return True
  1894. + elif "subject_mimetype" in dikt: return True
  1895. + elif "subject_text" in dikt: return True
  1896. + elif "subject_storage" in dikt: return True
  1897. + return False
  1898. +
  1899. + def __repr__(self):
  1900. + return "%s(%s)" %(
  1901. + self.__class__.__name__, super(Event, self).__repr__()
  1902. + )
  1903. +
  1904. + def append_subject(self, subject=None):
  1905. + """
  1906. + Append a new empty Subject and return a reference to it
  1907. + """
  1908. + if not subject:
  1909. + subject = self._subject_type()
  1910. + self.subjects.append(subject)
  1911. + return subject
  1912. +
  1913. + def get_subjects(self):
  1914. + return self[1]
  1915. +
  1916. + def set_subjects(self, subjects):
  1917. + self[1] = subjects
  1918. + subjects = property(get_subjects, set_subjects,
  1919. + doc="Read/write property with a list of :class:`Subjects <Subject>`")
  1920. +
  1921. + def get_id(self):
  1922. + val = self[0][Event.Id]
  1923. + return int(val) if val else 0
  1924. + id = property(get_id,
  1925. + doc="Read only property containing the the event id if the event has one")
  1926. +
  1927. + def get_timestamp(self):
  1928. + return self[0][Event.Timestamp]
  1929. +
  1930. + def set_timestamp(self, value):
  1931. + self[0][Event.Timestamp] = str(value)
  1932. + timestamp = property(get_timestamp, set_timestamp,
  1933. + doc="Read/write property with the event timestamp defined as milliseconds since the Epoch. By default it is set to the moment of instance creation")
  1934. +
  1935. + def get_interpretation(self):
  1936. + return self[0][Event.Interpretation]
  1937. +
  1938. + def set_interpretation(self, value):
  1939. + self[0][Event.Interpretation] = value
  1940. + interpretation = property(get_interpretation, set_interpretation,
  1941. + doc="Read/write property defining the interpretation type of the event")
  1942. +
  1943. + def get_manifestation(self):
  1944. + return self[0][Event.Manifestation]
  1945. +
  1946. + def set_manifestation(self, value):
  1947. + self[0][Event.Manifestation] = value
  1948. + manifestation = property(get_manifestation, set_manifestation,
  1949. + doc="Read/write property defining the manifestation type of the event")
  1950. +
  1951. + def get_actor(self):
  1952. + return self[0][Event.Actor]
  1953. +
  1954. + def set_actor(self, value):
  1955. + self[0][Event.Actor] = value
  1956. + actor = property(get_actor, set_actor,
  1957. + doc="Read/write property defining the application or entity responsible "
  1958. + "for emitting the event. For applications, the format of this field is "
  1959. + "the base filename of the corresponding .desktop file with an "
  1960. + "`application://` URI scheme. For example, "
  1961. + "`/usr/share/applications/firefox.desktop` is encoded as "
  1962. + "`application://firefox.desktop`")
  1963. +
  1964. + def get_origin(self):
  1965. + return self[0][Event.Origin]
  1966. +
  1967. + def set_origin(self, value):
  1968. + self[0][Event.Origin] = value
  1969. + origin = property(get_origin, set_origin,
  1970. + doc="Read/write property defining the origin where the event was emitted.")
  1971. +
  1972. + def get_payload(self):
  1973. + return self[2]
  1974. +
  1975. + def set_payload(self, value):
  1976. + self[2] = value
  1977. + payload = property(get_payload, set_payload,
  1978. + doc="Free form attachment for the event. Transfered over DBus as an array of bytes")
  1979. +
  1980. + def matches_template(self, event_template):
  1981. + """
  1982. + Return True if this event matches *event_template*. The
  1983. + matching is done where unset fields in the template is
  1984. + interpreted as wild cards. Interpretations and manifestations
  1985. + are also matched if they are children of the types specified
  1986. + in `event_template`. If the template has more than one
  1987. + subject, this event matches if at least one of the subjects
  1988. + on this event matches any single one of the subjects on the
  1989. + template.
  1990. +
  1991. + Basically this method mimics the matching behaviour
  1992. + found in the :meth:`FindEventIds` method on the Zeitgeist engine.
  1993. + """
  1994. + # We use direct member access to speed things up a bit
  1995. + # First match the raw event data
  1996. + data = self[0]
  1997. + tdata = event_template[0]
  1998. + for m in Event.Fields:
  1999. + if m == Event.Timestamp or not tdata[m]:
  2000. + # matching be timestamp is not supported and
  2001. + # empty template-fields are treated as wildcards
  2002. + continue
  2003. + if m in (Event.Manifestation, Event.Interpretation):
  2004. + # special check for symbols
  2005. + comp = Symbol.uri_is_child_of
  2006. + else:
  2007. + comp = EQUAL
  2008. + if not self._check_field_match(m, tdata[m], comp):
  2009. + return False
  2010. +
  2011. + # If template has no subjects we have a match
  2012. + if len(event_template[1]) == 0 : return True
  2013. +
  2014. + # Now we check the subjects
  2015. + for tsubj in event_template[1]:
  2016. + for subj in self[1]:
  2017. + if not subj.matches_template(tsubj) : continue
  2018. + # We have a matching subject, all good!
  2019. + return True
  2020. +
  2021. + # Template has subjects, but we never found a match
  2022. + return False
  2023. +
  2024. + def _check_field_match(self, field_id, expression, comp):
  2025. + """ Checks if an expression matches a field given by its `field_id`
  2026. + using a `comp` comparison function """
  2027. + if field_id in self.SUPPORTS_NEGATION \
  2028. + and expression.startswith(NEGATION_OPERATOR):
  2029. + return not self._check_field_match(field_id, expression[len(NEGATION_OPERATOR):], comp)
  2030. + elif field_id in self.SUPPORTS_WILDCARDS \
  2031. + and expression.endswith(WILDCARD):
  2032. + assert comp == EQUAL, "wildcards only work for pure text fields"
  2033. + return self._check_field_match(field_id, expression[:-len(WILDCARD)], STARTSWITH)
  2034. + else:
  2035. + return comp(self[0][field_id], expression)
  2036. +
  2037. + def matches_event (self, event):
  2038. + """
  2039. + Interpret *self* as the template an match *event* against it.
  2040. + This method is the dual method of :meth:`matches_template`.
  2041. + """
  2042. + return event.matches_template(self)
  2043. +
  2044. + def in_time_range (self, time_range):
  2045. + """
  2046. + Check if the event timestamp lies within a :class:`TimeRange`
  2047. + """
  2048. + t = int(self.timestamp) # The timestamp may be stored as a string
  2049. + return (t >= time_range.begin) and (t <= time_range.end)
  2050. +
  2051. +class DataSource(list):
  2052. + """ Optimized and convenient data structure representing a datasource.
  2053. +
  2054. + This class is designed so that you can pass it directly over
  2055. + DBus using the Python DBus bindings. It will automagically be
  2056. + marshalled with the signature a(asaasay). See also the section
  2057. + on the :ref:`event serialization format <event_serialization_format>`.
  2058. +
  2059. + This class does integer based lookups everywhere and can wrap any
  2060. + conformant data structure without the need for marshalling back and
  2061. + forth between DBus wire format. These two properties makes it highly
  2062. + efficient and is recommended for use everywhere.
  2063. +
  2064. + This is part of the :const:`org.gnome.zeitgeist.DataSourceRegistry`
  2065. + extension.
  2066. + """
  2067. + Fields = (UniqueId,
  2068. + Name,
  2069. + Description,
  2070. + EventTemplates,
  2071. + Running,
  2072. + LastSeen, # last time the data-source did something (connected,
  2073. + # inserted events, disconnected).
  2074. + Enabled) = list(range(7))
  2075. +
  2076. + def get_unique_id(self):
  2077. + return self[self.UniqueId]
  2078. +
  2079. + def set_unique_id(self, value):
  2080. + self[self.UniqueId] = value
  2081. +
  2082. + def get_name(self):
  2083. + return self[self.Name]
  2084. +
  2085. + def set_name(self, value):
  2086. + self[self.Name] = value
  2087. +
  2088. + def get_description(self):
  2089. + return self[self.Description]
  2090. +
  2091. + def set_description(self, value):
  2092. + self[self.Description] = value
  2093. +
  2094. + def get_running(self):
  2095. + return self[self.Running]
  2096. +
  2097. + def set_running(self,value):
  2098. + self[self.Running] = value
  2099. +
  2100. + def get_running(self):
  2101. + return self[self.Running]
  2102. +
  2103. + def running(self, value):
  2104. + self[self.Running] = value
  2105. +
  2106. + def get_last_seen(self):
  2107. + return self[self.LastSeen]
  2108. +
  2109. + def set_last_seen(self, value):
  2110. + self[self.LastSeen] = value
  2111. +
  2112. + def get_enabled(self):
  2113. + return self[self.Enabled]
  2114. +
  2115. + def set_enabled(self, value):
  2116. + self[self.Enabled] = value
  2117. +
  2118. + unique_id = property(get_unique_id, set_unique_id)
  2119. + name = property(get_name, set_name)
  2120. + description = property(get_description, set_description)
  2121. + running = property(get_running, set_running)
  2122. + last_seen = property(get_last_seen, set_last_seen)
  2123. + enabled = property(get_enabled, set_enabled)
  2124. +
  2125. + def __init__(self, unique_id, name, description, templates, running=True,
  2126. + last_seen=None, enabled=True):
  2127. + """
  2128. + Create a new DataSource object using the given parameters.
  2129. +
  2130. + If you want to instantiate this class from a dbus.Struct, you can
  2131. + use: DataSource(*data_source), where data_source is the dbus.Struct.
  2132. + """
  2133. + super(DataSource, self).__init__()
  2134. + self.append(unique_id)
  2135. + self.append(name)
  2136. + self.append(description)
  2137. + self.append(templates)
  2138. + self.append(bool(running))
  2139. + self.append(last_seen if last_seen else get_timestamp_for_now())
  2140. + self.append(enabled)
  2141. +
  2142. + def __eq__(self, source):
  2143. + return self[self.UniqueId] == source[self.UniqueId]
  2144. +
  2145. + def __repr__(self):
  2146. + return "%s: %s (%s)" % (self.__class__.__name__, self[self.UniqueId],
  2147. + self[self.Name])
  2148. +
  2149. +
  2150. +NULL_EVENT = ([], [], [])
  2151. +"""Minimal Event representation, a tuple containing three empty lists.
  2152. +This `NULL_EVENT` is used by the API to indicate a queried but not
  2153. +available (not found or blocked) Event.
  2154. +"""
  2155. +
  2156. +class _Enumeration(object):
  2157. +
  2158. + @classmethod
  2159. + def iteritems(self):
  2160. + """
  2161. + Return an iterator yielding (name, value) tuples for all items in
  2162. + this enumeration.
  2163. + """
  2164. + return iter([(x, getattr(self, x)) for x in [x for x in sorted(self.__dict__) if not x.startswith('__')]])
  2165. +
  2166. +class RelevantResultType(_Enumeration):
  2167. + """
  2168. + An enumeration class used to define how query results should be returned
  2169. + from the Zeitgeist engine.
  2170. + """
  2171. +
  2172. + Recent = EnumValue(0, "All uris with the most recent uri first")
  2173. + Related = EnumValue(1, "All uris with the most related one first")
  2174. +
  2175. +class StorageState(_Enumeration):
  2176. + """
  2177. + Enumeration class defining the possible values for the storage state
  2178. + of an event subject.
  2179. +
  2180. + The StorageState enumeration can be used to control whether or not matched
  2181. + events must have their subjects available to the user. Fx. not including
  2182. + deleted files, files on unplugged USB drives, files available only when
  2183. + a network is available etc.
  2184. + """
  2185. +
  2186. + NotAvailable = EnumValue(0, "The storage medium of the events "
  2187. + "subjects must not be available to the user")
  2188. + Available = EnumValue(1, "The storage medium of all event subjects "
  2189. + "must be immediately available to the user")
  2190. + Any = EnumValue(2, "The event subjects may or may not be available")
  2191. +
  2192. +class ResultType(_Enumeration):
  2193. + """
  2194. + An enumeration class used to define how query results should be returned
  2195. + from the Zeitgeist engine.
  2196. + """
  2197. +
  2198. + MostRecentEvents = EnumValue(0,
  2199. + "All events with the most recent events first")
  2200. + LeastRecentEvents = EnumValue(1, "All events with the oldest ones first")
  2201. + MostRecentSubjects = EnumValue(2, "One event for each subject only, "
  2202. + "ordered with the most recent events first")
  2203. + LeastRecentSubjects = EnumValue(3, "One event for each subject only, "
  2204. + "ordered with oldest events first")
  2205. + MostPopularSubjects = EnumValue(4, "One event for each subject only, "
  2206. + "ordered by the popularity of the subject")
  2207. + LeastPopularSubjects = EnumValue(5, "One event for each subject only, "
  2208. + "ordered ascendingly by popularity of the subject")
  2209. + MostPopularActor = EnumValue(6, "The last event of each different actor,"
  2210. + "ordered by the popularity of the actor")
  2211. + LeastPopularActor = EnumValue(7, "The last event of each different actor,"
  2212. + "ordered ascendingly by the popularity of the actor")
  2213. + MostRecentActor = EnumValue(8,
  2214. + "The Actor that has been used to most recently")
  2215. + LeastRecentActor = EnumValue(9,
  2216. + "The Actor that has been used to least recently")
  2217. + MostRecentOrigin = EnumValue(10,
  2218. + "The last event of each different subject origin")
  2219. + LeastRecentOrigin = EnumValue(11, "The last event of each different "
  2220. + "subject origin, ordered by least recently used first")
  2221. + MostPopularOrigin = EnumValue(12, "The last event of each different "
  2222. + "subject origin, ordered by the popularity of the origins")
  2223. + LeastPopularOrigin = EnumValue(13, "The last event of each different "
  2224. + "subject origin, ordered ascendingly by the popularity of the origin")
  2225. + OldestActor = EnumValue(14, "The first event of each different actor")
  2226. + MostRecentSubjectInterpretation = EnumValue(15, "One event for each "
  2227. + "subject interpretation only, ordered with the most recent "
  2228. + "events first")
  2229. + LeastRecentSubjectInterpretation = EnumValue(16, "One event for each "
  2230. + "subject interpretation only, ordered with the least recent "
  2231. + "events first")
  2232. + MostPopularSubjectInterpretation = EnumValue(17, "One event for each "
  2233. + "subject interpretation only, ordered by the popularity of the "
  2234. + "subject interpretation")
  2235. + LeastPopularSubjectInterpretation = EnumValue(18, "One event for each "
  2236. + "subject interpretation only, ordered ascendingly by popularity of "
  2237. + "the subject interpretation")
  2238. + MostRecentMimeType = EnumValue(19, "One event for each mimetype only, "
  2239. + "ordered with the most recent events first")
  2240. + LeastRecentMimeType = EnumValue(20, "One event for each mimetype only, "
  2241. + "ordered with the least recent events first")
  2242. + MostPopularMimeType = EnumValue(21, "One event for each mimetype only, "
  2243. + "ordered by the popularity of the mimetype")
  2244. + LeastPopularMimeType = EnumValue(22, "One event for each mimetype only, "
  2245. + "ordered ascendingly by popularity of the mimetype")
  2246. + MostRecentCurrentUri = EnumValue(23, "One event for each subject only "
  2247. + "(by current_uri instead of uri), "
  2248. + "ordered with the most recent events first")
  2249. + LeastRecentCurrentUri = EnumValue(24, "One event for each subject only "
  2250. + "(by current_uri instead of uri), "
  2251. + "ordered with oldest events first")
  2252. + MostPopularCurrentUri = EnumValue(25, "One event for each subject only "
  2253. + "(by current_uri instead of uri), "
  2254. + "ordered by the popularity of the subject")
  2255. + LeastPopularCurrentUri = EnumValue(26, "One event for each subject only "
  2256. + "(by current_uri instead of uri), "
  2257. + "ordered ascendingly by popularity of the subject")
  2258. + MostRecentEventOrigin = EnumValue(27,
  2259. + "The last event of each different origin")
  2260. + LeastRecentEventOrigin = EnumValue(28, "The last event of each "
  2261. + " different origin, ordered by least recently used first")
  2262. + MostPopularEventOrigin = EnumValue(29, "The last event of each "
  2263. + "different origin, ordered by the popularity of the origins")
  2264. + LeastPopularEventOrigin = EnumValue(30, "The last event of each "
  2265. + "different origin, ordered ascendingly by the popularity of the origin")
  2266. + MostRecentCurrentOrigin = EnumValue(31,
  2267. + "The last event of each different subject origin")
  2268. + LeastRecentCurrentOrigin = EnumValue(32, "The last event of each different "
  2269. + "subject origin, ordered by least recently used first")
  2270. + MostPopularCurrentOrigin = EnumValue(33, "The last event of each different "
  2271. + "subject origin, ordered by the popularity of the origins")
  2272. + LeastPopularCurrentOrigin = EnumValue(34, "The last event of each different "
  2273. + "subject origin, ordered ascendingly by the popularity of the origin")
  2274. +
  2275. + # We should eventually migrate over to those names to disambiguate
  2276. + # subject origin and event origin:
  2277. + MostRecentSubjectOrigin = MostRecentOrigin
  2278. + LeastRecentSubjectOrigin = LeastRecentOrigin
  2279. + MostPopularSubjectOrigin = MostPopularOrigin
  2280. + LeastPopularSubjectOrigin = LeastPopularOrigin
  2281. +
  2282. +INTERPRETATION_DOC = \
  2283. +"""In general terms the *interpretation* of an event or subject is an abstract
  2284. +description of *"what happened"* or *"what is this"*.
  2285. +
  2286. +Each interpretation type is uniquely identified by a URI. This class provides
  2287. +a list of hard coded URI constants for programming convenience. In addition;
  2288. +each interpretation instance in this class has a *display_name* property, which
  2289. +is an internationalized string meant for end user display.
  2290. +
  2291. +The interpretation types listed here are all subclasses of *str* and may be
  2292. +used anywhere a string would be used.
  2293. +
  2294. +Interpretations form a hierarchical type tree. So that fx. Audio, Video, and
  2295. +Image all are sub types of Media. These types again have their own sub types,
  2296. +like fx. Image has children Icon, Photo, and VectorImage (among others).
  2297. +
  2298. +Templates match on all sub types, so that a query on subjects with
  2299. +interpretation Media also match subjects with interpretations
  2300. +Audio, Photo, and all other sub types of Media.
  2301. +"""
  2302. +
  2303. +MANIFESTATION_DOC = \
  2304. +"""The manifestation type of an event or subject is an abstract classification
  2305. +of *"how did this happen"* or *"how does this item exist"*.
  2306. +
  2307. +Each manifestation type is uniquely identified by a URI. This class provides
  2308. +a list of hard coded URI constants for programming convenience. In addition;
  2309. +each interpretation instance in this class has a *display_name* property, which
  2310. +is an internationalized string meant for end user display.
  2311. +
  2312. +The manifestation types listed here are all subclasses of *str* and may be
  2313. +used anywhere a string would be used.
  2314. +
  2315. +Manifestations form a hierarchical type tree. So that fx. ArchiveItem,
  2316. +Attachment, and RemoteDataObject all are sub types of FileDataObject.
  2317. +These types can again have their own sub types.
  2318. +
  2319. +Templates match on all sub types, so that a query on subjects with manifestation
  2320. +FileDataObject also match subjects of types Attachment or ArchiveItem and all
  2321. +other sub types of FileDataObject
  2322. +"""
  2323. +
  2324. +start_symbols = time.time()
  2325. +
  2326. +Interpretation = Symbol("Interpretation", doc=INTERPRETATION_DOC)
  2327. +Manifestation = Symbol("Manifestation", doc=MANIFESTATION_DOC)
  2328. +_SYMBOLS_BY_URI["Interpretation"] = Interpretation
  2329. +_SYMBOLS_BY_URI["Manifestation"] = Manifestation
  2330. +
  2331. +# Load the ontology definitions
  2332. +ontology_file = os.path.join(os.path.dirname(__file__), "_ontology.py")
  2333. +try:
  2334. + exec(compile(open(ontology_file, "rb").read(), ontology_file, 'exec'))
  2335. +except IOError:
  2336. + raise ImportError("Unable to load Zeitgeist ontology. Did you run `make`?")
  2337. +
  2338. +#
  2339. +# Bootstrap the symbol relations. We use a 2-pass strategy:
  2340. +#
  2341. +# 1) Make sure that all parents and children are registered on each symbol
  2342. +for symbol in _SYMBOLS_BY_URI.values():
  2343. + for parent in symbol._parents:
  2344. + try:
  2345. + _SYMBOLS_BY_URI[parent]._children[symbol.uri] = None
  2346. + except KeyError as e:
  2347. + print("ERROR", e, parent, symbol.uri)
  2348. + pass
  2349. + for child in symbol._children:
  2350. + try:
  2351. + _SYMBOLS_BY_URI[child]._parents.add(symbol.uri)
  2352. + except KeyError:
  2353. + print("ERROR", e, child, symbol.uri)
  2354. + pass
  2355. +
  2356. +# 2) Resolve all child and parent URIs to their actual Symbol instances
  2357. +for symbol in _SYMBOLS_BY_URI.values():
  2358. + for child_uri in symbol._children.keys():
  2359. + symbol._children[child_uri] = _SYMBOLS_BY_URI[child_uri]
  2360. +
  2361. + parents = {}
  2362. + for parent_uri in symbol._parents:
  2363. + parents[parent_uri] = _SYMBOLS_BY_URI[parent_uri]
  2364. + symbol._parents = parents
  2365. +
  2366. +
  2367. +if __name__ == "__main__":
  2368. + print("Success")
  2369. + end_symbols = time.time()
  2370. + print("Import time: %s" % (end_symbols - start_symbols), file=sys.stderr)
  2371. +
  2372. +# vim:noexpandtab:ts=4:sw=4
  2373. diff -Naur zeitgeist-explorer-0.2.orig/zgexplorer/eventwidgets.py zeitgeist-explorer-0.2/zgexplorer/eventwidgets.py
  2374. --- zeitgeist-explorer-0.2.orig/zgexplorer/eventwidgets.py 2019-03-31 12:36:02.066670337 +0000
  2375. +++ zeitgeist-explorer-0.2/zgexplorer/eventwidgets.py 2019-03-31 13:38:49.036523440 +0000
  2376. @@ -21,7 +21,7 @@
  2377. from datetime import datetime
  2378. from gi.repository import Gtk, Gdk, Gio
  2379. -from zeitgeist.datamodel import Event, Subject, Manifestation, \
  2380. +from zgexplorer.datamodel import Event, Subject, Manifestation, \
  2381. Interpretation, StorageState, Symbol, ResultType
  2382. @@ -57,7 +57,7 @@
  2383. def insert(self, events):
  2384. for event in events:
  2385. - if event.id not in self.events.keys():
  2386. + if event.id not in list(self.events.keys()):
  2387. self.events[event.id] = event
  2388. self.treeview.add_events(events)
  2389. @@ -129,7 +129,7 @@
  2390. def add_event(self, event):
  2391. self._store.append([event.id, event.date_string,
  2392. - event.interp_string, event.manif_string, unicode(event.actor)])
  2393. + event.interp_string, event.manif_string, str(event.actor)])
  2394. #event_iter = self._store.append(None, [event.id, event.date_string,
  2395. # event.interp_string, event.manif_string, unicode(event.actor)])
  2396. #for subject in event.subjects:
  2397. @@ -138,7 +138,7 @@
  2398. #self.expand_row(event_iter)
  2399. def add_events(self, events):
  2400. - map(self.add_event, events)
  2401. + list(map(self.add_event, events))
  2402. def set_events(self, events):
  2403. self._store.clear()
  2404. diff -Naur zeitgeist-explorer-0.2.orig/zgexplorer/monitorviewer.py zeitgeist-explorer-0.2/zgexplorer/monitorviewer.py
  2405. --- zeitgeist-explorer-0.2.orig/zgexplorer/monitorviewer.py 2019-03-31 12:36:02.066670337 +0000
  2406. +++ zeitgeist-explorer-0.2/zgexplorer/monitorviewer.py 2019-03-31 13:39:09.473245700 +0000
  2407. @@ -27,7 +27,7 @@
  2408. from zgexplorer.eventwidgets import EventDetailsViewer, EventsTreeView, EventsViewer
  2409. from zgexplorer.remote import get_zeitgeist
  2410. -from zeitgeist.datamodel import Event, Subject, Interpretation, \
  2411. +from zgexplorer.datamodel import Event, Subject, Interpretation, \
  2412. Manifestation, StorageState, ResultType, Symbol
  2413. class MonitorViewer(Gtk.VBox):
  2414. diff -Naur zeitgeist-explorer-0.2.orig/zgexplorer/_ontology.py zeitgeist-explorer-0.2/zgexplorer/_ontology.py
  2415. --- zeitgeist-explorer-0.2.orig/zgexplorer/_ontology.py 1970-01-01 00:00:00.000000000 +0000
  2416. +++ zeitgeist-explorer-0.2/zgexplorer/_ontology.py 2019-01-14 10:45:25.000000000 +0000
  2417. @@ -0,0 +1,95 @@
  2418. +#
  2419. +# Auto-generated from .trig files. Do not edit.
  2420. +#
  2421. +Symbol('ALARM', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#Alarm', display_name='Alarm', doc='Provide a grouping of component properties that define an alarm.', auto_resolve=False)
  2422. +Symbol('ATTACHMENT', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Attachment']), uri='http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#Attachment', display_name='Attachment', doc='An object attached to a calendar entity. This class has been introduced to serve as a structured value of the ncal:attach property. See the documentation of ncal:attach for details.', auto_resolve=False)
  2423. +Symbol('CALENDAR', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#Calendar', display_name='Calendar', doc='A calendar. Inspirations for this class can be traced to the VCALENDAR component defined in RFC 2445 sec. 4.4, but it may just as well be used to represent any kind of Calendar.', auto_resolve=False)
  2424. +Symbol('CALENDAR_DATA_OBJECT', parent=set(['Manifestation']), uri='http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#CalendarDataObject', display_name='CalendarDataObject', doc='A DataObject found in a calendar. It is usually interpreted as one of the calendar entity types (e.g. Event, Journal, Todo etc.)', auto_resolve=False)
  2425. +Symbol('EVENT', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#Event', display_name='Event', doc='Provide a grouping of component properties that describe an event.', auto_resolve=False)
  2426. +Symbol('FREEBUSY', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#Freebusy', display_name='Freebusy', doc='Provide a grouping of component properties that describe either a request for free/busy time, describe a response to a request for free/busy time or describe a published set of busy time.', auto_resolve=False)
  2427. +Symbol('JOURNAL', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#Journal', display_name='Journal', doc='Provide a grouping of component properties that describe a journal entry.', auto_resolve=False)
  2428. +Symbol('TIMEZONE', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#Timezone', display_name='Timezone', doc='Provide a grouping of component properties that defines a time zone.', auto_resolve=False)
  2429. +Symbol('TODO', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/04/02/ncal#Todo', display_name='Todo', doc='Provide a grouping of calendar properties that describe a to-do.', auto_resolve=False)
  2430. +Symbol('CONTACT', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact', display_name='Contact', doc='A Contact. A piece of data that can provide means to identify or communicate with an entity.', auto_resolve=False)
  2431. +Symbol('CONTACT_GROUP', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nco#ContactGroup', display_name='ContactGroup', doc='A group of Contacts. Could be used to express a group in an addressbook or on a contact list of an IM application. One contact can belong to many groups.', auto_resolve=False)
  2432. +Symbol('CONTACT_LIST', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nco#ContactList', display_name='ContactList', doc='A contact list, this class represents an addressbook or a contact list of an IM application. Contacts inside a contact list can belong to contact groups.', auto_resolve=False)
  2433. +Symbol('CONTACT_LIST_DATA_OBJECT', parent=set(['Manifestation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nco#ContactListDataObject', display_name='ContactListDataObject', doc='An entity occuring on a contact list (usually interpreted as an nco:Contact)', auto_resolve=False)
  2434. +Symbol('ORGANIZATION_CONTACT', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nco#OrganizationContact', display_name='OrganizationContact', doc='A Contact that denotes on Organization.', auto_resolve=False)
  2435. +Symbol('PERSON_CONTACT', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nco#Contact']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nco#PersonContact', display_name='PersonContact', doc='A Contact that denotes a Person. A person can have multiple Affiliations.', auto_resolve=False)
  2436. +Symbol('APPLICATION', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Software']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Application', display_name='Application', doc='An application', auto_resolve=False)
  2437. +Symbol('ARCHIVE', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#DataContainer']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Archive', display_name='Archive', doc='A compressed file. May contain other files or folder inside.', auto_resolve=False)
  2438. +Symbol('ARCHIVE_ITEM', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#EmbeddedFileDataObject']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#ArchiveItem', display_name='ArchiveItem', doc='A file entity inside an archive.', auto_resolve=False)
  2439. +Symbol('ATTACHMENT', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#EmbeddedFileDataObject']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Attachment', display_name='Attachment', doc='A file attached to another data object. Many data formats allow for attachments: emails, vcards, ical events, id3 and exif...', auto_resolve=False)
  2440. +Symbol('AUDIO', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Media']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Audio', display_name='Audio', doc='A file containing audio content', auto_resolve=False)
  2441. +Symbol('BOOKMARK', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Bookmark', display_name='Bookmark', doc='A bookmark of a webbrowser. Use nie:title for the name/label, nie:contentCreated to represent the date when the user added the bookmark, and nie:contentLastModified for modifications. nfo:bookmarks to store the link.', auto_resolve=False)
  2442. +Symbol('BOOKMARK_FOLDER', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#BookmarkFolder', display_name='Bookmark Folder', doc='A folder with bookmarks of a webbrowser. Use nfo:containsBookmark to relate Bookmarks. Folders can contain subfolders, use containsBookmarkFolder to relate them.', auto_resolve=False)
  2443. +Symbol('CURSOR', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RasterImage']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Cursor', display_name='Cursor', doc='A Cursor.', auto_resolve=False)
  2444. +Symbol('DATA_CONTAINER', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#DataContainer', display_name='DataContainer', doc='A superclass for all entities, whose primary purpose is to serve as containers for other data object. They usually don\'t have any "meaning" by themselves. Examples include folders, archives and optical disc images.', auto_resolve=False)
  2445. +Symbol('DELETED_RESOURCE', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#DeletedResource', display_name='DeletedResource', doc='A file entity that has been deleted from the original source. Usually such entities are stored within various kinds of \'Trash\' or \'Recycle Bin\' folders.', auto_resolve=False)
  2446. +Symbol('DOCUMENT', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document', display_name='Document', doc='A generic document. A common superclass for all documents on the desktop.', auto_resolve=False)
  2447. +Symbol('EMBEDDED_FILE_DATA_OBJECT', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#EmbeddedFileDataObject', display_name='EmbeddedFileDataObject', doc='A file embedded in another data object. There are many ways in which a file may be embedded in another one. Use this class directly only in cases if none of the subclasses gives a better description of your case.', auto_resolve=False)
  2448. +Symbol('EXECUTABLE', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Executable', display_name='Executable', doc='An executable file.', auto_resolve=False)
  2449. +Symbol('FILESYSTEM', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#DataContainer']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Filesystem', display_name='Filesystem', doc='A filesystem. Examples of filesystems include hard disk partitions, removable media, but also images thereof stored in files such as ISO.', auto_resolve=False)
  2450. +Symbol('FILESYSTEM_IMAGE', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Filesystem']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FilesystemImage', display_name='FilesystemImage', doc='An image of a filesystem. Instances of this class may include CD images, DVD images or hard disk partition images created by various pieces of software (e.g. Norton Ghost). Deprecated in favor of nfo:Filesystem.', auto_resolve=False)
  2451. +Symbol('FILE_DATA_OBJECT', parent=set(['Manifestation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject', display_name='file', doc='A resource containing a finite sequence of bytes with arbitrary information, that is available to a computer program and is usually based on some kind of durable storage. A file is durable in the sense that it remains available for programs to use after the current program has finished.', auto_resolve=False)
  2452. +Symbol('FOLDER', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#DataContainer']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Folder', display_name='Folder', doc='A folder/directory. Examples of folders include folders on a filesystem and message folders in a mailbox.', auto_resolve=False)
  2453. +Symbol('FONT', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Font', display_name='Font', doc='A font.', auto_resolve=False)
  2454. +Symbol('HARD_DISK_PARTITION', parent=set(['Manifestation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#HardDiskPartition', display_name='HardDiskPartition', doc='A partition on a hard disk', auto_resolve=False)
  2455. +Symbol('HTML_DOCUMENT', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#PlainTextDocument']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#HtmlDocument', display_name='HtmlDocument', doc='A HTML document, may contain links to other files.', auto_resolve=False)
  2456. +Symbol('ICON', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Image']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Icon', display_name='Icon', doc='An Icon (regardless of whether it\'s a raster or a vector icon. A resource representing an icon could have two types (Icon and Raster, or Icon and Vector) if required.', auto_resolve=False)
  2457. +Symbol('IMAGE', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Visual']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Image', display_name='Image', doc='A file containing an image.', auto_resolve=False)
  2458. +Symbol('MEDIA', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Media', display_name='Media', doc='A piece of media content. This class may be used to express complex media containers with many streams of various media content (both aural and visual).', auto_resolve=False)
  2459. +Symbol('MEDIA_LIST', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#MediaList', display_name='MediaList', doc='A file containing a list of media files.e.g. a playlist', auto_resolve=False)
  2460. +Symbol('MEDIA_STREAM', parent=set(['Manifestation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#MediaStream', display_name='MediaStream', doc='A stream of multimedia content, usually contained within a media container such as a movie (containing both audio and video) or a DVD (possibly containing many streams of audio and video). Most common interpretations for such a DataObject include Audio and Video.', auto_resolve=False)
  2461. +Symbol('MIND_MAP', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#MindMap', display_name='MindMap', doc='A MindMap, created by a mind-mapping utility. Examples might include FreeMind or mind mapper.', auto_resolve=False)
  2462. +Symbol('OPERATING_SYSTEM', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Software']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#OperatingSystem', display_name='OperatingSystem', doc='An OperatingSystem', auto_resolve=False)
  2463. +Symbol('PAGINATED_TEXT_DOCUMENT', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#TextDocument']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#PaginatedTextDocument', display_name='PaginatedTextDocument', doc='A file containing a text document, that is unambiguously divided into pages. Examples might include PDF, DOC, PS, DVI etc.', auto_resolve=False)
  2464. +Symbol('PLAIN_TEXT_DOCUMENT', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#TextDocument']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#PlainTextDocument', display_name='PlainTextDocument', doc='A file containing plain text (ASCII, Unicode or other encodings). Examples may include TXT, HTML, XML, program source code etc.', auto_resolve=False)
  2465. +Symbol('PRESENTATION', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Presentation', display_name='Presentation', doc='A Presentation made by some presentation software (Corel Presentations, OpenOffice Impress, MS Powerpoint etc.)', auto_resolve=False)
  2466. +Symbol('RASTER_IMAGE', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Image']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RasterImage', display_name='RasterImage', doc='A raster image.', auto_resolve=False)
  2467. +Symbol('REMOTE_DATA_OBJECT', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#FileDataObject']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RemoteDataObject', display_name='RemoteDataObject', doc='A file data object stored at a remote location. Don\'t confuse this class with a RemotePortAddress. This one applies to a particular resource, RemotePortAddress applies to an address, that can have various interpretations.', auto_resolve=False)
  2468. +Symbol('REMOTE_PORT_ADDRESS', parent=set(['Manifestation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#RemotePortAddress', display_name='RemotePortAddress', doc='An address specifying a remote host and port. Such an address can be interpreted in many ways (examples of such interpretations include mailboxes, websites, remote calendars or filesystems), depending on an interpretation, various kinds of data may be extracted from such an address.', auto_resolve=False)
  2469. +Symbol('SOFTWARE', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Software', display_name='Software', doc='A piece of software. Examples may include applications and the operating system. This interpretation most commonly applies to SoftwareItems.', auto_resolve=False)
  2470. +Symbol('SOFTWARE_ITEM', parent=set(['Manifestation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#SoftwareItem', display_name='SoftwareItem', doc='A DataObject representing a piece of software. Examples of interpretations of a SoftwareItem include an Application and an OperatingSystem.', auto_resolve=False)
  2471. +Symbol('SOFTWARE_SERVICE', parent=set(['Manifestation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#SoftwareService', display_name='SoftwareService', doc='A service published by a piece of software, either by an operating system or an application. Examples of such services may include calendar, addressbook and mailbox managed by a PIM application. This category is introduced to distinguish between data available directly from the applications (Via some Interprocess Communication Mechanisms) and data available from files on a disk. In either case both DataObjects would receive a similar interpretation (e.g. a Mailbox) and wouldn\'t differ on the content level.', auto_resolve=False)
  2472. +Symbol('SOURCE_CODE', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#PlainTextDocument']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#SourceCode', display_name='SourceCode', doc='Code in a compilable or interpreted programming language.', auto_resolve=False)
  2473. +Symbol('SPREADSHEET', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Spreadsheet', display_name='Spreadsheet', doc='A spreadsheet, created by a spreadsheet application. Examples might include Gnumeric, OpenOffice Calc or MS Excel.', auto_resolve=False)
  2474. +Symbol('TEXT_DOCUMENT', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Document']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#TextDocument', display_name='TextDocument', doc='A text document', auto_resolve=False)
  2475. +Symbol('TRASH', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#DataContainer']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Trash', display_name='Trash', doc='Represents a container for deleted files, a feature common in modern operating systems.', auto_resolve=False)
  2476. +Symbol('VECTOR_IMAGE', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Image']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#VectorImage', display_name='VectorImage', doc='', auto_resolve=False)
  2477. +Symbol('VIDEO', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Visual']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Video', display_name='Video', doc='A video file.', auto_resolve=False)
  2478. +Symbol('VISUAL', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Media']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Visual', display_name='Visual', doc='File containing visual content.', auto_resolve=False)
  2479. +Symbol('WEBSITE', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Website', display_name='Website', doc='A website, usually a container for remote resources, that may be interpreted as HTMLDocuments, images or other types of content.', auto_resolve=False)
  2480. +Symbol('WEB_DATA_OBJECT', parent=set(['Manifestation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#WebDataObject', display_name='web data object', doc='An information resources of which representations (files, streams) can be retrieved through a web server. They may be generated at retrieval time. Typical examples are pages served by PHP or AJAX or mp3 streams.', auto_resolve=False)
  2481. +Symbol('DATA_OBJECT', parent=set([]), uri='http://www.semanticdesktop.org/ontologies/2007/01/19/nie#DataObject', display_name='DataObject', doc='A unit of data that is created, annotated and processed on the user desktop. It represents a native structure the user works with. The usage of the term \'native\' is important. It means that a DataObject can be directly mapped to a data structure maintained by a native application. This may be a file, a set of files or a part of a file. The granularity depends on the user. This class is not intended to be instantiated by itself. Use more specific subclasses.', auto_resolve=False)
  2482. +Symbol('INFORMATION_ELEMENT', parent=set([]), uri='http://www.semanticdesktop.org/ontologies/2007/01/19/nie#InformationElement', display_name='InformationElement', doc='A unit of content the user works with. This is a superclass for all interpretations of a DataObject.', auto_resolve=False)
  2483. +Symbol('MOVIE', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Video']), uri='http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#Movie', display_name='movie', doc='A Movie', auto_resolve=False)
  2484. +Symbol('MUSIC_ALBUM', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#MediaList']), uri='http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#MusicAlbum', display_name='music album', doc='The music album as provided by the publisher. Not to be confused with media lists or collections.', auto_resolve=False)
  2485. +Symbol('MUSIC_PIECE', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Audio']), uri='http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#MusicPiece', display_name='music', doc='Used to assign music-specific properties such a BPM to video and audio', auto_resolve=False)
  2486. +Symbol('TVSERIES', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#TVSeries', display_name='tv series', doc='A TV Series has multiple seasons and episodes', auto_resolve=False)
  2487. +Symbol('TVSHOW', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nfo#Video']), uri='http://www.semanticdesktop.org/ontologies/2009/02/19/nmm#TVShow', display_name='tv show', doc='A TV Show', auto_resolve=False)
  2488. +Symbol('EMAIL', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Message']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Email', display_name='Email', doc='An email.', auto_resolve=False)
  2489. +Symbol('IMMESSAGE', parent=set(['http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Message']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#IMMessage', display_name='IMMessage', doc='A message sent with Instant Messaging software.', auto_resolve=False)
  2490. +Symbol('MAILBOX', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Mailbox', display_name='Mailbox', doc='A mailbox - container for MailboxDataObjects.', auto_resolve=False)
  2491. +Symbol('MAILBOX_DATA_OBJECT', parent=set(['Manifestation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#MailboxDataObject', display_name='MailboxDataObject', doc='An entity encountered in a mailbox. Most common interpretations for such an entity include Message or Folder', auto_resolve=False)
  2492. +Symbol('MESSAGE', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#Message', display_name='Message', doc='A message. Could be an email, instant messanging message, SMS message etc.', auto_resolve=False)
  2493. +Symbol('MIME_ENTITY', parent=set(['Interpretation']), uri='http://www.semanticdesktop.org/ontologies/2007/03/22/nmo#MimeEntity', display_name='MimeEntity', doc='A MIME entity, as defined in RFC2045, Section 2.4.', auto_resolve=False)
  2494. +Symbol('ACCEPT_EVENT', parent=set(['http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventInterpretation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#AcceptEvent', display_name='ACCEPT_EVENT', doc='Event triggered when the user accepts a request of some sort. Examples could be answering a phone call, accepting a file transfer, or accepting a friendship request over an IM protocol. See also DenyEvent for when the user denies a similar request', auto_resolve=False)
  2495. +Symbol('ACCESS_EVENT', parent=set(['http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventInterpretation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#AccessEvent', display_name='ACCESS_EVENT', doc='Event triggered by opening, accessing, or starting a resource. Most zg:AccessEvents will have an accompanying zg:LeaveEvent, but this need not always be the case', auto_resolve=False)
  2496. +Symbol('APPLICATION_ACTION', parent=set(['Interpretation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#ApplicationAction', display_name='APPLICATION_ACTION', doc='Representation of a specific Action on an Application', auto_resolve=False)
  2497. +Symbol('CREATE_EVENT', parent=set(['http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventInterpretation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#CreateEvent', display_name='CREATE_EVENT', doc='Event type triggered when an item is created', auto_resolve=False)
  2498. +Symbol('DELETE_EVENT', parent=set(['http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventInterpretation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#DeleteEvent', display_name='DELETE_EVENT', doc='Event triggered because a resource has been deleted or otherwise made permanently unavailable. Fx. when deleting a file. FIXME: How about when moving to trash?', auto_resolve=False)
  2499. +Symbol('DENY_EVENT', parent=set(['http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventInterpretation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#DenyEvent', display_name='DENY_EVENT', doc='Event triggered when the user denies a request of some sort. Examples could be rejecting a phone call, rejecting a file transfer, or denying a friendship request over an IM protocol. See also AcceptEvent for the converse event type', auto_resolve=False)
  2500. +Symbol('EVENT_INTERPRETATION', parent=set(['Interpretation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventInterpretation', display_name='EVENT_INTERPRETATION', doc='Base class for event interpretations. Please do no instantiate directly, but use one of the sub classes. The interpretation of an event describes \'what happened\' - fx. \'something was created\' or \'something was accessed\'', auto_resolve=False)
  2501. +Symbol('EVENT_MANIFESTATION', parent=set(['Manifestation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventManifestation', display_name='EVENT_MANIFESTATION', doc='Base class for event manifestation types. Please do no instantiate directly, but use one of the sub classes. The manifestation of an event describes \'how it happened\'. Fx. \'the user did this\' or \'the system notified the user\'', auto_resolve=False)
  2502. +Symbol('EXPIRE_EVENT', parent=set(['http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventInterpretation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#ExpireEvent', display_name='EXPIRE_EVENT', doc='Event triggered when something expires or times out. These types of events are normally not triggered by the user, but by the operating system or some external party. Examples are a recurring calendar item or task deadline that expires or a when the user fails to respond to an external request such as a phone call', auto_resolve=False)
  2503. +Symbol('HEURISTIC_ACTIVITY', parent=set(['http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventManifestation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#HeuristicActivity', display_name='HEURISTIC_ACTIVITY', doc='An event that is caused indirectly from user activity or deducted via analysis of other events. Fx. if an algorithm divides a user workflow into disjoint \'projects\' based on temporal analysis it could insert heuristic events when the user changed project', auto_resolve=False)
  2504. +Symbol('LEAVE_EVENT', parent=set(['http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventInterpretation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#LeaveEvent', display_name='LEAVE_EVENT', doc='Event triggered by closing, leaving, or stopping a resource. Most zg:LeaveEvents will be following a zg:Access event, but this need not always be the case', auto_resolve=False)
  2505. +Symbol('MODIFY_EVENT', parent=set(['http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventInterpretation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#ModifyEvent', display_name='MODIFY_EVENT', doc='Event triggered by modifying an existing resources. Fx. when editing and saving a file on disk or correcting a typo in the name of a contact', auto_resolve=False)
  2506. +Symbol('MOVE_EVENT', parent=set(['http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventInterpretation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#MoveEvent', display_name='MOVE_EVENT', doc='Event triggered when a resource has been moved from a location to another. Fx. moving a file from a folder to another.', auto_resolve=False)
  2507. +Symbol('RECEIVE_EVENT', parent=set(['http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventInterpretation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#ReceiveEvent', display_name='RECEIVE_EVENT', doc='Event triggered when something is received from an external party. The event manifestation must be set according to the world view of the receiving party. Most often the item that is being received will be some sort of message - an email, instant message, or broadcasted media such as micro blogging', auto_resolve=False)
  2508. +Symbol('SCHEDULED_ACTIVITY', parent=set(['http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventManifestation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#ScheduledActivity', display_name='SCHEDULED_ACTIVITY', doc='An event that was directly triggered by some user initiated sequence of actions. For example a music player automatically changing to the next song in a playlist', auto_resolve=False)
  2509. +Symbol('SEND_EVENT', parent=set(['http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventInterpretation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#SendEvent', display_name='SEND_EVENT', doc='Event triggered when something is send to an external party. The event manifestation must be set according to the world view of the sending party. Most often the item that is being send will be some sort of message - an email, instant message, or broadcasted media such as micro blogging', auto_resolve=False)
  2510. +Symbol('SYSTEM_NOTIFICATION', parent=set(['http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventManifestation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#SystemNotification', display_name='SYSTEM_NOTIFICATION', doc='An event send to the user by the operating system. Examples could include when the user inserts a USB stick or when the system warns that the hard disk is full', auto_resolve=False)
  2511. +Symbol('USER_ACTIVITY', parent=set(['http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventManifestation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#UserActivity', display_name='USER_ACTIVITY', doc='An event that was actively performed by the user. For example saving or opening a file by clicking on it in the file manager', auto_resolve=False)
  2512. +Symbol('WORLD_ACTIVITY', parent=set(['http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#EventManifestation']), uri='http://www.zeitgeist-project.com/ontologies/2010/01/27/zg#WorldActivity', display_name='WORLD_ACTIVITY', doc='An event that was performed by an entity, usually human or organization, other than the user. An example could be logging the activities of other people in a team', auto_resolve=False)
  2513. diff -Naur zeitgeist-explorer-0.2.orig/zgexplorer/remote.py zeitgeist-explorer-0.2/zgexplorer/remote.py
  2514. --- zeitgeist-explorer-0.2.orig/zgexplorer/remote.py 2019-03-31 12:36:02.070003679 +0000
  2515. +++ zeitgeist-explorer-0.2/zgexplorer/remote.py 2019-03-31 13:39:22.079946616 +0000
  2516. @@ -20,8 +20,8 @@
  2517. from datetime import datetime
  2518. -from zeitgeist.client import ZeitgeistClient
  2519. -from zeitgeist.datamodel import *
  2520. +from zgexplorer.client import ZeitgeistClient
  2521. +from zgexplorer.datamodel import *
  2522. __all__ = ['get_zeitgeist']
  2523. diff -Naur zeitgeist-explorer-0.2.orig/zgexplorer/templates.py zeitgeist-explorer-0.2/zgexplorer/templates.py
  2524. --- zeitgeist-explorer-0.2.orig/zgexplorer/templates.py 2019-03-31 12:36:02.070003679 +0000
  2525. +++ zeitgeist-explorer-0.2/zgexplorer/templates.py 2019-03-31 13:39:45.300009618 +0000
  2526. @@ -19,7 +19,7 @@
  2527. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  2528. #
  2529. -from zeitgeist.datamodel import Event, Subject, Interpretation, \
  2530. +from zgexplorer.datamodel import Event, Subject, Interpretation, \
  2531. Manifestation, StorageState, ResultType, TimeRange
  2532. all_events = ["All Events", \