[output] Create preliminary framework for output handling
Prepare a framework for having modular outputs. Essentially, the main application uses a output-type object to format strings for the preamble, the actual data items, and a "postamble" (finalizer). The printing of that representation, again, is up to the main application, not the output framework. Probably, at some point in the future, an interface class will be in order, but right now, I want to keep it lean - seeing as for the forseeable future, i3bar is going to be the one and only consumer of this.
This commit is contained in:
parent
3dd69c71c2
commit
c4683f3700
4 changed files with 33 additions and 0 deletions
0
bumblebee/__init__.py
Normal file
0
bumblebee/__init__.py
Normal file
0
bumblebee/outputs/__init__.py
Normal file
0
bumblebee/outputs/__init__.py
Normal file
13
bumblebee/outputs/i3.py
Normal file
13
bumblebee/outputs/i3.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
import json
|
||||
|
||||
class i3bar:
|
||||
def preamble(self):
|
||||
return json.dumps({ "version": 1 }) + "["
|
||||
|
||||
def data(self, data):
|
||||
return json.dumps(data) + ","
|
||||
|
||||
def finalize(self):
|
||||
return "]"
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
20
i3bumblebee
Executable file
20
i3bumblebee
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import bumblebee.outputs.i3
|
||||
|
||||
def main():
|
||||
output = bumblebee.outputs.i3.i3bar()
|
||||
|
||||
print output.preamble()
|
||||
|
||||
while True:
|
||||
# TODO: retrieve data from modules
|
||||
data = []
|
||||
print output.data(data)
|
||||
|
||||
print output.finalize()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
Loading…
Reference in a new issue