Juan Hernandez has uploaded a new change for review. Change subject: cli: Don't write .0 suffix for integers ......................................................................
cli: Don't write .0 suffix for integers Currently when we write a floating point number we use the standard Python representation, which always include a dot and the non integer part, even if the non integer part is zero. For example: # show statistic --host-identifier myhost id : 7816602b-c05c-3db7-a4da-3769f7ad8896 name : memory.total description : Total memory host-id : d3560912-f2ad-11e1-8f5f-001a4a169798 type : GAUGE unit : BYTES values-type : INTEGER values-value-datum: 33658241024.0 This patch changes the CLI so that it will only write the non integer part if it isn't zero. Change-Id: I21490ec50e3a7433331e981162de800c7d548f27 Bug-Url: https://bugzilla.redhat.com/855724 Signed-off-by: Juan Hernandez <[email protected]> --- M src/ovirtcli/format/text.py 1 file changed, 6 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine-cli refs/changes/64/26864/1 diff --git a/src/ovirtcli/format/text.py b/src/ovirtcli/format/text.py index 177a4af..9254dea 100644 --- a/src/ovirtcli/format/text.py +++ b/src/ovirtcli/format/text.py @@ -125,6 +125,12 @@ val = value else: val = str(value) + + # Don't write the .0 suffix for floating point number whose value is + # actually an integer: + if type(value) == float and val.endswith('.0'): + val = val[:-2] + fil = (field if resource_context is None else resource_context.lower() + '.' + field)\ .replace('.', '-') -- To view, visit http://gerrit.ovirt.org/26864 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I21490ec50e3a7433331e981162de800c7d548f27 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine-cli Gerrit-Branch: master Gerrit-Owner: Juan Hernandez <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
