Signed-off-by: Philipp Hahn <hahn(a)univention.de>
---
examples/event-test.py | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/examples/event-test.py b/examples/event-test.py
index 91a7cb7..d2d2c60 100755
--- a/examples/event-test.py
+++ b/examples/event-test.py
@@ -456,6 +456,31 @@ def virEventLoopNativeStart():
##########################################################################
# Everything that now follows is a simple demo of domain lifecycle events
##########################################################################
+class Description(object):
+ __slots__ = ('desc', 'args')
+
+ def __init__(self, *args, **kwargs):
+ self.desc = kwargs.get('desc')
+ self.args = args
+
+ def __str__(self): # type: () -> str
+ return self.desc
+
+ def __getitem__(self, item): # type: (int) -> str
+ try:
+ data = self.args[item]
+ except IndexError:
+ return self.__class__(desc=str(item))
+
+ if isinstance(data, str):
+ return self.__class__(desc=data)
+ elif isinstance(data, (list, tuple)):
+ desc, args = data
+ return self.__class__(*args, desc=desc)
+
+ raise TypeError(args)
+
+
def domEventToString(event):
domEventStrings = ( "Defined",
"Undefined",
--
2.11.0