[core/output] Small refactoring
This commit is contained in:
parent
f645203579
commit
c44744fa50
1 changed files with 7 additions and 3 deletions
|
@ -30,15 +30,19 @@ class I3BarOutput(object):
|
||||||
"""Finish i3bar protocol"""
|
"""Finish i3bar protocol"""
|
||||||
sys.stdout.write("]\n")
|
sys.stdout.write("]\n")
|
||||||
|
|
||||||
|
def draw_widget(self, result, widget):
|
||||||
|
"""Draw a single widget"""
|
||||||
|
result.append({
|
||||||
|
u"full_text": widget.full_text()
|
||||||
|
})
|
||||||
|
|
||||||
def draw(self, widgets, engine=None):
|
def draw(self, widgets, engine=None):
|
||||||
"""Draw a number of widgets"""
|
"""Draw a number of widgets"""
|
||||||
if not isinstance(widgets, list):
|
if not isinstance(widgets, list):
|
||||||
widgets = [widgets]
|
widgets = [widgets]
|
||||||
result = []
|
result = []
|
||||||
for widget in widgets:
|
for widget in widgets:
|
||||||
result.append({
|
self.draw_widget(result, widget)
|
||||||
u"full_text": widget.full_text()
|
|
||||||
})
|
|
||||||
sys.stdout.write(json.dumps(result))
|
sys.stdout.write(json.dumps(result))
|
||||||
|
|
||||||
def flush(self):
|
def flush(self):
|
||||||
|
|
Loading…
Reference in a new issue