[libcamera-devel,05/10] utils: raspberrypi: ctt: json_pretty_print: Skip all spaces

Message ID 20200703001422.24324-6-laurent.pinchart@ideasonboard.com
State Accepted
Headers show
Series
  • utils: raspberrypi: ctt: Improve JSON pretty printer
Related show

Commit Message

Laurent Pinchart July 3, 2020, 12:14 a.m. UTC
Skip all white space characters, not just ' '. This makes a difference
if the input JSON data is already formatted.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 utils/raspberrypi/ctt/ctt_pretty_print_json.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch

diff --git a/utils/raspberrypi/ctt/ctt_pretty_print_json.py b/utils/raspberrypi/ctt/ctt_pretty_print_json.py
index 3de8c108f01c..dfa99a6d4034 100644
--- a/utils/raspberrypi/ctt/ctt_pretty_print_json.py
+++ b/utils/raspberrypi/ctt/ctt_pretty_print_json.py
@@ -52,8 +52,6 @@  class JSONPrettyPrinter(object):
         elif c == ':':
             self.fout.write(c)
             self.fout.write(' ')
-        elif c == ' ':
-            pass
         elif c == ',':
             if not self.state["inarray"][0]:
                 self.fout.write(c)
@@ -67,6 +65,8 @@  class JSONPrettyPrinter(object):
                     self.newline()
                 else:
                     self.fout.write(' ')
+        elif c.isspace():
+            pass
         else:
             self.fout.write(c)
         self.state["skipnewline"] = (c == '[')