Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2020-12-25 16:05:28 +0300
committerDanielle Adams <adamzdanielle@gmail.com>2021-01-12 15:09:28 +0300
commit8ad3455ae3738d6e5e6e9fb7de996f2a34ac7c75 (patch)
treef400e930693321e5ff8e70aa7eb980339cff591d /tools
parent34d1d791e56e0d2053af6a8eb483edeec0e57609 (diff)
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: https://github.com/nodejs/node/pull/36626 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Christian Clauss <cclauss@me.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/install.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/tools/install.py b/tools/install.py
index 729b416fc47..693faff4c37 100755
--- a/tools/install.py
+++ b/tools/install.py
@@ -19,8 +19,8 @@ def abspath(*args):
return os.path.abspath(path)
def load_config():
- s = open('config.gypi').read()
- return ast.literal_eval(s)
+ with open('config.gypi') as f:
+ return ast.literal_eval(f.read())
def try_unlink(path):
try:
@@ -223,11 +223,19 @@ def run(args):
cmd = args[1] if len(args) > 1 else 'install'
if os.environ.get('HEADERS_ONLY'):
- if cmd == 'install': return headers(install)
- if cmd == 'uninstall': return headers(uninstall)
+ if cmd == 'install':
+ headers(install)
+ return
+ if cmd == 'uninstall':
+ headers(uninstall)
+ return
else:
- if cmd == 'install': return files(install)
- if cmd == 'uninstall': return files(uninstall)
+ if cmd == 'install':
+ files(install)
+ return
+ if cmd == 'uninstall':
+ files(uninstall)
+ return
raise RuntimeError('Bad command: %s\n' % cmd)