qmp-shell: Sort by key when pretty-printing
PATCH 1/1 qmp-shell: Sort by key when pretty-printing
If the user selects pretty-printing (-p) the contents of any dictionaries in the output are sorted by key.
--- scripts/qmp/qmp-shell | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/qmp/qmp-shell +1 -1
@@ -260,7 +260,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): indent = None if self._pretty: indent = 4 - jsobj = json.dumps(qmp, indent=indent) + jsobj = json.dumps(qmp, indent=indent, sort_keys=self._pretty) print(str(jsobj)) def _execute_cmd(self, cmdline):
Signature · 1 line
2.28.0
Quoted 14 lines · David Edmondson
If the user selects pretty-printing (-p) the contents of any dictionaries in the output are sorted by key.
Signed-off-by David Edmondson <[email protected]>--- scripts/qmp/qmp-shell | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/qmp/qmp-shell +0
-0
scripts/qmp/qmp-shell class QMPShell(qmp.QEMUMonitorProtocol): · line 266
Quoted 8 lines
scripts/qmp/qmp-shell +1
-1@@ -260,7 +260,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): indent = None if self._pretty: indent = 4 - jsobj = json.dumps(qmp, indent=indent) + jsobj = json.dumps(qmp, indent=indent, sort_keys=self._pretty) print(str(jsobj)) def _execute_cmd(self, cmdline):
Markus Armbruster
AppliedQuoted 13 lines · David Edmondson
If the user selects pretty-printing (-p) the contents of any dictionaries in the output are sorted by key.
Signed-off-by David Edmondson <[email protected]>--- scripts/qmp/qmp-shell | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/qmp/qmp-shell +0
-0
scripts/qmp/qmp-shell class QMPShell(qmp.QEMUMonitorProtocol): · line 266
Quoted 8 lines
scripts/qmp/qmp-shell +1
-1@@ -260,7 +260,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): indent = None if self._pretty: indent = 4 - jsobj = json.dumps(qmp, indent=indent) + jsobj = json.dumps(qmp, indent=indent, sort_keys=self._pretty) print(str(jsobj)) def _execute_cmd(self, cmdline):
Queued, thanks!
Quoted 14 lines · David Edmondson
If the user selects pretty-printing (-p) the contents of any dictionaries in the output are sorted by key.
Signed-off-by David Edmondson <[email protected]>--- scripts/qmp/qmp-shell | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/qmp/qmp-shell +0
-0
scripts/qmp/qmp-shell class QMPShell(qmp.QEMUMonitorProtocol): · line 266
Quoted 8 lines
scripts/qmp/qmp-shell +1
-1@@ -260,7 +260,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): indent = None if self._pretty: indent = 4 - jsobj = json.dumps(qmp, indent=indent) + jsobj = json.dumps(qmp, indent=indent, sort_keys=self._pretty) print(str(jsobj)) def _execute_cmd(self, cmdline):
Hi, out of curiosity, what does this help you accomplish?
I've recently been overhauling a LOT of the Python utilities we have, so I'm interested in hearing about how people use these tools and what they'd like them to do.
--js
Quoted 21 lines · John Snow
Quoted 20 lines · David Edmondson
If the user selects pretty-printing (-p) the contents of any dictionaries in the output are sorted by key.
Signed-off-by David Edmondson <[email protected]>--- scripts/qmp/qmp-shell | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/qmp/qmp-shell +1
-1@@ -260,7 +260,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): indent = None if self._pretty: indent = 4 - jsobj = json.dumps(qmp, indent=indent) + jsobj = json.dumps(qmp, indent=indent, sort_keys=self._pretty) print(str(jsobj))
Quoted 4 lines
scripts/qmp/qmp-shell class QMPShell(qmp.QEMUMonitorProtocol): · line 266
Quoted 2 lines
scripts/qmp/qmp-shell +0
-0def _execute_cmd(self, cmdline):Hi, out of curiosity, what does this help you accomplish?
When dumping a dictionary with many values, visually finding a specific one that is of interest is much quicker if they are sorted. Nothing more than that.
Quoted 5 lines
I've recently been overhauling a LOT of the Python utilities we have, so I'm interested in hearing about how people use these tools and what they'd like them to do.
--js
dme.
Signature · 1 line
I can't explain, you would not understand. This is not how I am.
Quoted 23 lines · David Edmondson
Quoted 21 lines · John Snow
Quoted 20 lines · David Edmondson
If the user selects pretty-printing (-p) the contents of any dictionaries in the output are sorted by key.
Signed-off-by David Edmondson <[email protected]>--- scripts/qmp/qmp-shell | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/qmp/qmp-shell +1
-1@@ -260,7 +260,7 @@ class QMPShell(qmp.QEMUMonitorProtocol): indent = None if self._pretty: indent = 4 - jsobj = json.dumps(qmp, indent=indent) + jsobj = json.dumps(qmp, indent=indent, sort_keys=self._pretty) print(str(jsobj))
Quoted 9 lines
Quoted 4 lines
scripts/qmp/qmp-shell class QMPShell(qmp.QEMUMonitorProtocol): · line 266
Quoted 2 lines
scripts/qmp/qmp-shell +0
-0def _execute_cmd(self, cmdline):Hi, out of curiosity, what does this help you accomplish?
When dumping a dictionary with many values, visually finding a specific one that is of interest is much quicker if they are sorted. Nothing more than that.
Okay, simple! thanks for the input.
If you ever have any other laundry list desires or feedback for qmp-shell, let me know, as I intend to overhaul it soon.
(I may turn it into a GSoC project, too.)
--js