Skip to content

Commit 8ad3455

Browse files
Trottdanielleadams
authored andcommitted
tools: revise install.py for minor improvements
* Use an with block for reading the config file. Refs: https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files * Use explicit blank return to make it clear that the return value is not actually used and that it is being used for flow control only.. PR-URL: #36626 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Christian Clauss <[email protected]>
1 parent 34d1d79 commit 8ad3455

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

‎tools/install.py‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def abspath(*args):
1919
returnos.path.abspath(path)
2020

2121
defload_config():
22-
s=open('config.gypi').read()
23-
returnast.literal_eval(s)
22+
withopen('config.gypi')asf:
23+
returnast.literal_eval(f.read())
2424

2525
deftry_unlink(path):
2626
try:
@@ -223,11 +223,19 @@ def run(args):
223223
cmd=args[1] iflen(args) >1else'install'
224224

225225
ifos.environ.get('HEADERS_ONLY'):
226-
ifcmd=='install': returnheaders(install)
227-
ifcmd=='uninstall': returnheaders(uninstall)
226+
ifcmd=='install':
227+
headers(install)
228+
return
229+
ifcmd=='uninstall':
230+
headers(uninstall)
231+
return
228232
else:
229-
ifcmd=='install': returnfiles(install)
230-
ifcmd=='uninstall': returnfiles(uninstall)
233+
ifcmd=='install':
234+
files(install)
235+
return
236+
ifcmd=='uninstall':
237+
files(uninstall)
238+
return
231239

232240
raiseRuntimeError('Bad command: %s\n'%cmd)
233241

0 commit comments

Comments
(0)