[core/output] Small refactoring

This commit is contained in:
Tobi-wan Kenobi 2016-12-08 09:04:47 +01:00
parent f645203579
commit c44744fa50

View file

@ -30,15 +30,19 @@ class I3BarOutput(object):
"""Finish i3bar protocol"""
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):
"""Draw a number of widgets"""
if not isinstance(widgets, list):
widgets = [widgets]
result = []
for widget in widgets:
result.append({
u"full_text": widget.full_text()
})
self.draw_widget(result, widget)
sys.stdout.write(json.dumps(result))
def flush(self):