Browse Source

Add renderer and a default method for XGP

Alois Mahdal 10 years ago
parent
commit
f7fb7e4dc8
1 changed files with 21 additions and 0 deletions
  1. 21
    0
      include/gmon.py

+ 21
- 0
include/gmon.py View File

@@ -4,6 +4,24 @@
4 4
 class GmonPluginError(Exception):
5 5
     pass
6 6
 
7
+class XGPRenderer(object):
8
+
9
+    def __init__(self, txt=None):
10
+        self.txt = txt
11
+        self.img = None
12
+        self.tool = txt
13
+        self.bar = None
14
+        self.click = None
15
+        self._fields = ['txt', 'img', 'tool', 'bar', 'click']
16
+
17
+    def __str__(self):
18
+        out = ""
19
+        for field in self._fields:
20
+            value = getattr(self, field, None)
21
+            if value is not None:
22
+                out += "<%(f)s>%(v)s</%(f)s>" % {'f': field, 'v': value}
23
+        return out
24
+
7 25
 
8 26
 class BasePlugin(object):
9 27
 
@@ -18,3 +36,6 @@ class BasePlugin(object):
18 36
 
19 37
         render_fn = getattr(self, method_n, ex)
20 38
         return render_fn()
39
+
40
+    def render_xgp(self):
41
+        return XGPRenderer(self.render_plain())