From 511fbe987bd4c823bda99f123037fb0113fe58a5 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 12 Dec 2022 13:41:48 -0500 Subject: [PATCH] Suppress redundant output when writing to non-tty --- confluent_client/confluent/screensqueeze.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/confluent_client/confluent/screensqueeze.py b/confluent_client/confluent/screensqueeze.py index 6e8f0c99..7fc42207 100644 --- a/confluent_client/confluent/screensqueeze.py +++ b/confluent_client/confluent/screensqueeze.py @@ -50,9 +50,9 @@ class ScreenPrinter(object): if len(text) >= self.textlen: self.textlen = len(text) + 1 self.fieldwidth = self.textlen + self.nodenamelen + 1 - self.drawscreen() + self.drawscreen(node) - def drawscreen(self): + def drawscreen(self, node=None): if self.squeeze: currheight, currwidth = get_screengeom() currheight -= 1 @@ -76,7 +76,11 @@ class ScreenPrinter(object): break sys.stdout.write('\n') else: - for node in self.nodelist: + if node: + nodes = [node] + else: + nodes = self.nodelist + for node in nodes: sys.stdout.write(fieldformat.format(node, self.nodeoutput[node])) sys.stdout.write('\n') sys.stdout.flush()