* [PATCH] qmp-shell: Sort by key when pretty-printing
@ 2020-10-13 14:14 David Edmondson
2020-10-13 14:19 ` Philippe Mathieu-Daudé
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: David Edmondson @ 2020-10-13 14:14 UTC (permalink / raw)
To: qemu-devel, qemu-trivial; +Cc: David Edmondson, Markus Armbruster
If the user selects pretty-printing (-p) the contents of any
dictionaries in the output are sorted by key.
Signed-off-by: David Edmondson <david.edmondson@oracle.com>
---
scripts/qmp/qmp-shell | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
index c5eef06f3f..b4d06096ab 100755
--- a/scripts/qmp/qmp-shell
+++ b/scripts/qmp/qmp-shell
@@ -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):
--
2.28.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] qmp-shell: Sort by key when pretty-printing
2020-10-13 14:14 [PATCH] qmp-shell: Sort by key when pretty-printing David Edmondson
@ 2020-10-13 14:19 ` Philippe Mathieu-Daudé
2020-10-20 6:43 ` Markus Armbruster
2020-11-30 20:56 ` John Snow
2 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-10-13 14:19 UTC (permalink / raw)
To: David Edmondson, qemu-devel, qemu-trivial; +Cc: Markus Armbruster
On 10/13/20 4:14 PM, David Edmondson wrote:
> If the user selects pretty-printing (-p) the contents of any
> dictionaries in the output are sorted by key.
>
> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
> ---
> scripts/qmp/qmp-shell | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
> index c5eef06f3f..b4d06096ab 100755
> --- a/scripts/qmp/qmp-shell
> +++ b/scripts/qmp/qmp-shell
> @@ -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):
>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] qmp-shell: Sort by key when pretty-printing
2020-10-13 14:14 [PATCH] qmp-shell: Sort by key when pretty-printing David Edmondson
2020-10-13 14:19 ` Philippe Mathieu-Daudé
@ 2020-10-20 6:43 ` Markus Armbruster
2020-11-30 20:56 ` John Snow
2 siblings, 0 replies; 6+ messages in thread
From: Markus Armbruster @ 2020-10-20 6:43 UTC (permalink / raw)
To: David Edmondson; +Cc: qemu-trivial, qemu-devel
David Edmondson <david.edmondson@oracle.com> writes:
> If the user selects pretty-printing (-p) the contents of any
> dictionaries in the output are sorted by key.
>
> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
> ---
> scripts/qmp/qmp-shell | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
> index c5eef06f3f..b4d06096ab 100755
> --- a/scripts/qmp/qmp-shell
> +++ b/scripts/qmp/qmp-shell
> @@ -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!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] qmp-shell: Sort by key when pretty-printing
2020-10-13 14:14 [PATCH] qmp-shell: Sort by key when pretty-printing David Edmondson
2020-10-13 14:19 ` Philippe Mathieu-Daudé
2020-10-20 6:43 ` Markus Armbruster
@ 2020-11-30 20:56 ` John Snow
2020-11-30 21:57 ` David Edmondson
2 siblings, 1 reply; 6+ messages in thread
From: John Snow @ 2020-11-30 20:56 UTC (permalink / raw)
To: David Edmondson, qemu-devel, qemu-trivial; +Cc: Markus Armbruster
On 10/13/20 10:14 AM, David Edmondson wrote:
> If the user selects pretty-printing (-p) the contents of any
> dictionaries in the output are sorted by key.
>
> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
> ---
> scripts/qmp/qmp-shell | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
> index c5eef06f3f..b4d06096ab 100755
> --- a/scripts/qmp/qmp-shell
> +++ b/scripts/qmp/qmp-shell
> @@ -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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] qmp-shell: Sort by key when pretty-printing
2020-11-30 20:56 ` John Snow
@ 2020-11-30 21:57 ` David Edmondson
2020-12-01 15:17 ` John Snow
0 siblings, 1 reply; 6+ messages in thread
From: David Edmondson @ 2020-11-30 21:57 UTC (permalink / raw)
To: John Snow, qemu-devel, qemu-trivial; +Cc: Markus Armbruster
On Monday, 2020-11-30 at 15:56:51 -05, John Snow wrote:
> On 10/13/20 10:14 AM, David Edmondson wrote:
>> If the user selects pretty-printing (-p) the contents of any
>> dictionaries in the output are sorted by key.
>>
>> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
>> ---
>> scripts/qmp/qmp-shell | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
>> index c5eef06f3f..b4d06096ab 100755
>> --- a/scripts/qmp/qmp-shell
>> +++ b/scripts/qmp/qmp-shell
>> @@ -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?
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.
> 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.
--
I can't explain, you would not understand. This is not how I am.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] qmp-shell: Sort by key when pretty-printing
2020-11-30 21:57 ` David Edmondson
@ 2020-12-01 15:17 ` John Snow
0 siblings, 0 replies; 6+ messages in thread
From: John Snow @ 2020-12-01 15:17 UTC (permalink / raw)
To: David Edmondson, qemu-devel, qemu-trivial; +Cc: Markus Armbruster
On 11/30/20 4:57 PM, David Edmondson wrote:
> On Monday, 2020-11-30 at 15:56:51 -05, John Snow wrote:
>
>> On 10/13/20 10:14 AM, David Edmondson wrote:
>>> If the user selects pretty-printing (-p) the contents of any
>>> dictionaries in the output are sorted by key.
>>>
>>> Signed-off-by: David Edmondson <david.edmondson@oracle.com>
>>> ---
>>> scripts/qmp/qmp-shell | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
>>> index c5eef06f3f..b4d06096ab 100755
>>> --- a/scripts/qmp/qmp-shell
>>> +++ b/scripts/qmp/qmp-shell
>>> @@ -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?
>
> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-12-01 15:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-13 14:14 [PATCH] qmp-shell: Sort by key when pretty-printing David Edmondson
2020-10-13 14:19 ` Philippe Mathieu-Daudé
2020-10-20 6:43 ` Markus Armbruster
2020-11-30 20:56 ` John Snow
2020-11-30 21:57 ` David Edmondson
2020-12-01 15:17 ` John Snow
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).