[chirp_devel] [PATCH 3/6] Add newline at end of console status (#2343)

Dan Smith
Thu Mar 5 15:17:48 PST 2015


> Add newline at end of console status (#2343)
> 
> When downloading/uploading on the console, a pretty status bar is
> printed on a single line.  At the end of the transfer, a newline needs
> to be added, or subsequent output will appear on the same line as the
> status bar.
> 
> diff --git a/chirp/chirp_common.py b/chirp/chirp_common.py
> index 16cbf40..0a34adc 100644
> --- a/chirp/chirp_common.py
> +++ b/chirp/chirp_common.py
> @@ -1218,7 +1218,10 @@ class Status:
>              pct = 0.0
>              ticks = "?" * 10
>  
> -        return "|%-10s| %2.1f%% %s" % (ticks, pct, self.msg)
> +        s = "|%-10s| %2.1f%% %s" % (ticks, pct, self.msg)
> +        if self.cur == self.max:
> +            s += "\n"
> +        return s

This seems like a layering violation. If I stringify a thing, I expect
it to be mostly consistent and not imply details of how I'm using the
string. Further, your '\n' at the end isn't valid on all platforms and
won't have the desired effect there. You'll end up with a \n\r at the
end of the last loop instead of a \r\n, which is what you'd want on Windows.

Why wouldn't we just print the newline once we're done spewing these
lines from the caller and not make this inner thing do something based
on how it thinks it's being called?

--Dan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
Url : http://intrepid.danplanet.com/pipermail/chirp_devel/attachments/20150305/384d4269/attachment-0001.bin 


More information about the chirp_devel mailing list