diff options
author | Daniel Kutik <daniel.kutik@lavawerk.com> | 2022-12-13 12:44:47 +0100 |
---|---|---|
committer | Daniel Kutik <daniel.kutik@lavawerk.com> | 2022-12-13 16:23:28 +0000 |
commit | e641281d144cca09a451497209e748056cdd79bb (patch) | |
tree | f71da9752eebcecd54ddfe7c7e3d6c7986137d24 | |
parent | 035f22abec2263a48770bffbe04e4cfdc443ff41 (diff) | |
download | git-repo-e641281d144cca09a451497209e748056cdd79bb.tar.gz |
Use print with flush=True instead of stdout.flush
Resolves multiple TODOs. Since we are requiring Python 3,
we move to using print function with flush=True instead of
using sys.stdout.flush().
Change-Id: I54db0344ec78ac81a8d6c6c7e43ee7d301f42f02
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/354701
Tested-by: Daniel Kutik <daniel.kutik@lavawerk.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
-rw-r--r-- | subcmds/init.py | 12 | ||||
-rw-r--r-- | subcmds/upload.py | 8 |
2 files changed, 5 insertions, 15 deletions
diff --git a/subcmds/init.py b/subcmds/init.py index d732374d..26cac62f 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -134,9 +134,7 @@ to update the working directory files. | |||
134 | sys.exit(1) | 134 | sys.exit(1) |
135 | 135 | ||
136 | def _Prompt(self, prompt, value): | 136 | def _Prompt(self, prompt, value): |
137 | print('%-10s [%s]: ' % (prompt, value), end='') | 137 | print('%-10s [%s]: ' % (prompt, value), end='', flush=True) |
138 | # TODO: When we require Python 3, use flush=True w/print above. | ||
139 | sys.stdout.flush() | ||
140 | a = sys.stdin.readline().strip() | 138 | a = sys.stdin.readline().strip() |
141 | if a == '': | 139 | if a == '': |
142 | return value | 140 | return value |
@@ -173,9 +171,7 @@ to update the working directory files. | |||
173 | if not opt.quiet: | 171 | if not opt.quiet: |
174 | print() | 172 | print() |
175 | print('Your identity is: %s <%s>' % (name, email)) | 173 | print('Your identity is: %s <%s>' % (name, email)) |
176 | print('is this correct [y/N]? ', end='') | 174 | print('is this correct [y/N]? ', end='', flush=True) |
177 | # TODO: When we require Python 3, use flush=True w/print above. | ||
178 | sys.stdout.flush() | ||
179 | a = sys.stdin.readline().strip().lower() | 175 | a = sys.stdin.readline().strip().lower() |
180 | if a in ('yes', 'y', 't', 'true'): | 176 | if a in ('yes', 'y', 't', 'true'): |
181 | break | 177 | break |
@@ -217,9 +213,7 @@ to update the working directory files. | |||
217 | out.printer(fg='black', attr=c)(' %-6s ', c) | 213 | out.printer(fg='black', attr=c)(' %-6s ', c) |
218 | out.nl() | 214 | out.nl() |
219 | 215 | ||
220 | print('Enable color display in this user account (y/N)? ', end='') | 216 | print('Enable color display in this user account (y/N)? ', end='', flush=True) |
221 | # TODO: When we require Python 3, use flush=True w/print above. | ||
222 | sys.stdout.flush() | ||
223 | a = sys.stdin.readline().strip().lower() | 217 | a = sys.stdin.readline().strip().lower() |
224 | if a in ('y', 'yes', 't', 'true', 'on'): | 218 | if a in ('y', 'yes', 't', 'true', 'on'): |
225 | gc.SetString('color.ui', 'auto') | 219 | gc.SetString('color.ui', 'auto') |
diff --git a/subcmds/upload.py b/subcmds/upload.py index ceab6463..5b17fb51 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
@@ -293,9 +293,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
293 | for commit in commit_list: | 293 | for commit in commit_list: |
294 | print(' %s' % commit) | 294 | print(' %s' % commit) |
295 | 295 | ||
296 | print('to %s (y/N)? ' % remote.review, end='') | 296 | print('to %s (y/N)? ' % remote.review, end='', flush=True) |
297 | # TODO: When we require Python 3, use flush=True w/print above. | ||
298 | sys.stdout.flush() | ||
299 | if opt.yes: | 297 | if opt.yes: |
300 | print('<--yes>') | 298 | print('<--yes>') |
301 | answer = True | 299 | answer = True |
@@ -437,9 +435,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
437 | print('Uncommitted changes in %s (did you forget to amend?):' | 435 | print('Uncommitted changes in %s (did you forget to amend?):' |
438 | % branch.project.name) | 436 | % branch.project.name) |
439 | print('\n'.join(changes)) | 437 | print('\n'.join(changes)) |
440 | print('Continue uploading? (y/N) ', end='') | 438 | print('Continue uploading? (y/N) ', end='', flush=True) |
441 | # TODO: When we require Python 3, use flush=True w/print above. | ||
442 | sys.stdout.flush() | ||
443 | if opt.yes: | 439 | if opt.yes: |
444 | print('<--yes>') | 440 | print('<--yes>') |
445 | a = 'yes' | 441 | a = 'yes' |