{"id":8578,"url":"https://patchwork.libcamera.org/api/patches/8578/?format=json","web_url":"https://patchwork.libcamera.org/patch/8578/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200703001422.24324-10-laurent.pinchart@ideasonboard.com>","date":"2020-07-03T00:14:21","name":"[libcamera-devel,09/10] utils: raspberrypi: ctt: json_pretty_print: Avoid spaces at end of lines","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"bd3fecd68e18faeefffd1e5e0b075ecc2b2566fa","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/8578/mbox/","series":[{"id":1076,"url":"https://patchwork.libcamera.org/api/series/1076/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1076","date":"2020-07-03T00:14:12","name":"utils: raspberrypi: ctt: Improve JSON pretty printer","version":1,"mbox":"https://patchwork.libcamera.org/series/1076/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/8578/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8578/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 5A4EEBE905\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  3 Jul 2020 00:14:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2929460C62;\n\tFri,  3 Jul 2020 02:14:41 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 239AA60C63\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 Jul 2020 02:14:37 +0200 (CEST)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A7AB71450;\n\tFri,  3 Jul 2020 02:14:36 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"uejkICwv\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593735276;\n\tbh=NLtrgA4b/wli+aqEmSZI/blphIJQ64+h7IVFpFZn0FQ=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=uejkICwvcfAre708jbdTl/0o2qoOFIrTmw56/G5XF/+EFNulHMpa3MvAlqJN4mmeP\n\twyi6mMmcnFu/JuqtXDXmBWLegc8PkjE/7mbBOB11CtJGpbUaszd36/jedoUc77ttSg\n\ts+nibSRGRlb97dTmXj5rQcn8Qo9qvTjJTmuMJjOU=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri,  3 Jul 2020 03:14:21 +0300","Message-Id":"<20200703001422.24324-10-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20200703001422.24324-1-laurent.pinchart@ideasonboard.com>","References":"<20200703001422.24324-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 09/10] utils: raspberrypi: ctt:\n\tjson_pretty_print: Avoid spaces at end of lines","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Avoid outputting spaces at end of lines by recording the need for a\nspace and outputting it before the next character only if not a newline.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n utils/raspberrypi/ctt/ctt_pretty_print_json.py | 10 +++++++---\n 1 file changed, 7 insertions(+), 3 deletions(-)","diff":"diff --git a/utils/raspberrypi/ctt/ctt_pretty_print_json.py b/utils/raspberrypi/ctt/ctt_pretty_print_json.py\nindex f7fdb65116bc..2ca307a0af11 100644\n--- a/utils/raspberrypi/ctt/ctt_pretty_print_json.py\n+++ b/utils/raspberrypi/ctt/ctt_pretty_print_json.py\n@@ -18,6 +18,7 @@ class JSONPrettyPrinter(object):\n             \"arraycount\": [],\n             \"skipnewline\": True,\n             \"need_indent\": False,\n+            \"need_space\": False,\n         }\n \n         self.fout = fout\n@@ -26,12 +27,16 @@ class JSONPrettyPrinter(object):\n         if not self.state[\"skipnewline\"]:\n             self.fout.write('\\n')\n             self.state[\"need_indent\"] = True\n+            self.state[\"need_space\"] = False\n         self.state[\"skipnewline\"] = True\n \n     def write(self, c):\n         if self.state[\"need_indent\"]:\n             self.fout.write(' ' * self.state[\"indent\"] * 4)\n             self.state[\"need_indent\"] = False\n+        if self.state[\"need_space\"]:\n+            self.fout.write(' ')\n+            self.state[\"need_space\"] = False\n         self.fout.write(c)\n         self.state[\"skipnewline\"] = False\n \n@@ -60,11 +65,10 @@ class JSONPrettyPrinter(object):\n             self.write(c)\n         elif c == ':':\n             self.write(c)\n-            self.write(' ')\n+            self.state[\"need_space\"] = True\n         elif c == ',':\n             if not self.state[\"inarray\"][0]:\n                 self.write(c)\n-                self.write(' ')\n                 self.newline()\n             else:\n                 self.write(c)\n@@ -73,7 +77,7 @@ class JSONPrettyPrinter(object):\n                     self.state[\"arraycount\"][0] = 0\n                     self.newline()\n                 else:\n-                    self.write(' ')\n+                    self.state[\"need_space\"] = True\n         elif c.isspace():\n             pass\n         else:\n","prefixes":["libcamera-devel","09/10"]}