summaryrefslogtreecommitdiffstats
path: root/subcmds/init.py
diff options
context:
space:
mode:
authorDaniel Kutik <daniel.kutik@lavawerk.com>2022-12-13 12:44:47 +0100
committerDaniel Kutik <daniel.kutik@lavawerk.com>2022-12-13 16:23:28 +0000
commite641281d144cca09a451497209e748056cdd79bb (patch)
treef71da9752eebcecd54ddfe7c7e3d6c7986137d24 /subcmds/init.py
parent035f22abec2263a48770bffbe04e4cfdc443ff41 (diff)
downloadgit-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>
Diffstat (limited to 'subcmds/init.py')
-rw-r--r--subcmds/init.py12
1 files changed, 3 insertions, 9 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')