This isn't a program... this is a poem!
This commit is contained in:
parent
1d4403e308
commit
0ad4ae6a02
@ -64,8 +64,13 @@ class JSONIO:
|
|||||||
self.io.write(self.io.read())
|
self.io.write(self.io.read())
|
||||||
self.io.write(self.io.read())
|
self.io.write(self.io.read())
|
||||||
|
|
||||||
@contextmanager
|
|
||||||
def read(self):
|
def read(self):
|
||||||
|
while True:
|
||||||
|
with self.read_line() as j:
|
||||||
|
yield j
|
||||||
|
|
||||||
|
@contextmanager
|
||||||
|
def read_line(self):
|
||||||
line, prefix = self.io.read(), ""
|
line, prefix = self.io.read(), ""
|
||||||
|
|
||||||
# ignore comma at start of lines
|
# ignore comma at start of lines
|
||||||
@ -83,7 +88,7 @@ class I3statusHandler:
|
|||||||
if fd is None:
|
if fd is None:
|
||||||
fd = sys.stdin
|
fd = sys.stdin
|
||||||
|
|
||||||
self.io = IOHandler(fd)
|
self.io = JSONIO(IOHandler(fd))
|
||||||
|
|
||||||
def register(self, module):
|
def register(self, module):
|
||||||
"""Register a new module."""
|
"""Register a new module."""
|
||||||
@ -92,11 +97,8 @@ class I3statusHandler:
|
|||||||
module.registered(self)
|
module.registered(self)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
jio = JSONIO(self.io)
|
for j in self.io.read():
|
||||||
|
for module in self.modules:
|
||||||
while True:
|
output = module.output
|
||||||
with jio.read() as j:
|
if output:
|
||||||
for module in self.modules:
|
j.insert(0, output)
|
||||||
output = module.output
|
|
||||||
if output:
|
|
||||||
j.insert(0, output)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user