Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8ad3455

Browse filesBrowse 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 <duhamelantoine1995@gmail.com> Reviewed-By: Christian Clauss <cclauss@me.com>
1 parent 34d1d79 commit 8ad3455
Copy full SHA for 8ad3455

File tree

Expand file treeCollapse file tree

1 file changed

+14
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+14
-6
lines changed
Open diff view settings
Collapse file

‎tools/install.py‎

Copy file name to clipboardExpand all lines: tools/install.py
+14-6Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def abspath(*args):
1919
return os.path.abspath(path)
2020

2121
def load_config():
22-
s = open('config.gypi').read()
23-
return ast.literal_eval(s)
22+
with open('config.gypi') as f:
23+
return ast.literal_eval(f.read())
2424

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

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

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.