[Patchew-devel] [PATCH] patchew-cli: print well-formed JSON in "patchew-cli project --raw"

Paolo Bonzini posted 1 patch 6 years, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew-ci tags/patchew/20180320174501.5591-1-pbonzini@redhat.com
patchew-cli | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[Patchew-devel] [PATCH] patchew-cli: print well-formed JSON in "patchew-cli project --raw"
Posted by Paolo Bonzini 6 years, 1 month ago
"print(r)" use single quotes for dictionary keys.  Using json.dumps
makes sure that we produce valid JSON, and that is useful from tests.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
	I have not yet posted the test that uses this trivial change,
	but it is pretty obvious so I'm pushing it.

 patchew-cli | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/patchew-cli b/patchew-cli
index 51a89c5..5369ae3 100755
--- a/patchew-cli
+++ b/patchew-cli
@@ -223,7 +223,7 @@ class ProjectCommand(SubCommand):
         args = parser.parse_args(argv)
         r = self.api_do("get-projects")
         if args.raw:
-            print(r)
+            print(json.dumps(r, indent=2, separators=",:"))
             return 0
         for p in r:
             print(p["name"])
-- 
2.16.2

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel