diff options
author | Mike Frysinger <vapier@google.com> | 2019-07-04 17:35:11 -0400 |
---|---|---|
committer | David Pursehouse <dpursehouse@collab.net> | 2019-07-11 06:26:40 +0000 |
commit | ab85fe7c535bfa97c067354d8a23e39b849f6728 (patch) | |
tree | 3de17ed8b68af5cef82eaf5553ca3de41bd7e955 /subcmds/init.py | |
parent | 4f42a9706715c9c5add46632343f7108aabcd530 (diff) | |
download | git-repo-ab85fe7c535bfa97c067354d8a23e39b849f6728.tar.gz |
use print() instead of sys.stdout.write()
We're relying on sys.stdout.write() to flush its buffer which isn't
guaranteed, and is not the case in Python 3. Change to use print()
everywhere to be standard, and utilize the end= keyword to get the
EOL semantics we need.
We can't use print's flush= keyword as that's only in Python 3.
Leave behind a TODO to clean it up when we can drop Python 2.
Bug: https://crbug.com/gerrit/10418
Change-Id: I562128c7f1e6d154f4a6ecdf33a70fa2811dc2af
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/230392
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
Diffstat (limited to 'subcmds/init.py')
-rw-r--r-- | subcmds/init.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/subcmds/init.py b/subcmds/init.py index 6c8b1ddc..1c809ab4 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -294,7 +294,9 @@ to update the working directory files. | |||
294 | sys.exit(1) | 294 | sys.exit(1) |
295 | 295 | ||
296 | def _Prompt(self, prompt, value): | 296 | def _Prompt(self, prompt, value): |
297 | sys.stdout.write('%-10s [%s]: ' % (prompt, value)) | 297 | print('%-10s [%s]: ' % (prompt, value), end='') |
298 | # TODO: When we require Python 3, use flush=True w/print above. | ||
299 | sys.stdout.flush() | ||
298 | a = sys.stdin.readline().strip() | 300 | a = sys.stdin.readline().strip() |
299 | if a == '': | 301 | if a == '': |
300 | return value | 302 | return value |
@@ -328,7 +330,9 @@ to update the working directory files. | |||
328 | 330 | ||
329 | print() | 331 | print() |
330 | print('Your identity is: %s <%s>' % (name, email)) | 332 | print('Your identity is: %s <%s>' % (name, email)) |
331 | sys.stdout.write('is this correct [y/N]? ') | 333 | print('is this correct [y/N]? ', end='') |
334 | # TODO: When we require Python 3, use flush=True w/print above. | ||
335 | sys.stdout.flush() | ||
332 | a = sys.stdin.readline().strip().lower() | 336 | a = sys.stdin.readline().strip().lower() |
333 | if a in ('yes', 'y', 't', 'true'): | 337 | if a in ('yes', 'y', 't', 'true'): |
334 | break | 338 | break |
@@ -370,7 +374,9 @@ to update the working directory files. | |||
370 | out.printer(fg='black', attr=c)(' %-6s ', c) | 374 | out.printer(fg='black', attr=c)(' %-6s ', c) |
371 | out.nl() | 375 | out.nl() |
372 | 376 | ||
373 | sys.stdout.write('Enable color display in this user account (y/N)? ') | 377 | print('Enable color display in this user account (y/N)? ', end='') |
378 | # TODO: When we require Python 3, use flush=True w/print above. | ||
379 | sys.stdout.flush() | ||
374 | a = sys.stdin.readline().strip().lower() | 380 | a = sys.stdin.readline().strip().lower() |
375 | if a in ('y', 'yes', 't', 'true', 'on'): | 381 | if a in ('y', 'yes', 't', 'true', 'on'): |
376 | gc.SetString('color.ui', 'auto') | 382 | gc.SetString('color.ui', 'auto') |