Skip to content

Commit

Permalink
tools: revise install.py for minor improvements
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
Trott authored and targos committed May 1, 2021
1 parent 581a95f commit dd10afc
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tools/install.py
Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit dd10afc

Please sign in to comment.