Formatting: Format all python code with black.
This CL is probably not what you're looking for, it's only
automated formatting. Ignore it with
`git blame --ignore-rev <revision>` for this commit.
BUG=b:233893248
TEST=CQ
Change-Id: I66591d7a738d241aed3290138c0f68065ab10a6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3879174
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Alex Klein <saklein@chromium.org>
diff --git a/scripts/install_toolchain.py b/scripts/install_toolchain.py
index d83fb30..0e0c7e1 100644
--- a/scripts/install_toolchain.py
+++ b/scripts/install_toolchain.py
@@ -15,59 +15,78 @@
def GetParser():
- """Build the argument parser."""
- parser = commandline.ArgumentParser(description=__doc__)
+ """Build the argument parser."""
+ parser = commandline.ArgumentParser(description=__doc__)
- parser.add_argument('--noconfigure', dest='configure', default=True,
- action='store_false',
- help='Disable updating config files in <sysroot>/etc '
- 'after installation.')
- parser.add_argument('--force', default=False, action='store_true',
- help='Install toolchain even if already up to date.')
- parser.add_argument('--toolchain',
- help='Toolchain. For example: i686-pc-linux-gnu, '
- 'armv7a-softfloat-linux-gnueabi.')
- parser.add_argument('--sysroot', type='path', required=True,
- help='The sysroot to install the toolchain for.')
+ parser.add_argument(
+ "--noconfigure",
+ dest="configure",
+ default=True,
+ action="store_false",
+ help="Disable updating config files in <sysroot>/etc "
+ "after installation.",
+ )
+ parser.add_argument(
+ "--force",
+ default=False,
+ action="store_true",
+ help="Install toolchain even if already up to date.",
+ )
+ parser.add_argument(
+ "--toolchain",
+ help="Toolchain. For example: i686-pc-linux-gnu, "
+ "armv7a-softfloat-linux-gnueabi.",
+ )
+ parser.add_argument(
+ "--sysroot",
+ type="path",
+ required=True,
+ help="The sysroot to install the toolchain for.",
+ )
- return parser
+ return parser
def _GetToolchain(toolchain_name, sysroot):
- """Get the toolchain value or exit with an error message."""
- if toolchain_name:
- # Use the CLI argument when provided.
+ """Get the toolchain value or exit with an error message."""
+ if toolchain_name:
+ # Use the CLI argument when provided.
+ return toolchain_name
+
+ # Fetch the value from the sysroot.
+ toolchain_name = sysroot.GetStandardField(sysroot_lib.STANDARD_FIELD_CHOST)
+ if not toolchain_name:
+ cros_build_lib.Die(
+ "No toolchain specified in the sysroot or command line."
+ )
+
return toolchain_name
- # Fetch the value from the sysroot.
- toolchain_name = sysroot.GetStandardField(sysroot_lib.STANDARD_FIELD_CHOST)
- if not toolchain_name:
- cros_build_lib.Die('No toolchain specified in the sysroot or command line.')
-
- return toolchain_name
-
def _ParseArgs(argv):
- """Parse and validate arguments."""
- parser = GetParser()
- opts = parser.parse_args(argv)
+ """Parse and validate arguments."""
+ parser = GetParser()
+ opts = parser.parse_args(argv)
- # Expand the sysroot path to a sysroot object.
- opts.sysroot = sysroot_lib.Sysroot(opts.sysroot)
- # Make sure the toolchain value reflects the toolchain we will be using.
- opts.toolchain = _GetToolchain(opts.toolchain, opts.sysroot)
+ # Expand the sysroot path to a sysroot object.
+ opts.sysroot = sysroot_lib.Sysroot(opts.sysroot)
+ # Make sure the toolchain value reflects the toolchain we will be using.
+ opts.toolchain = _GetToolchain(opts.toolchain, opts.sysroot)
- opts.Freeze()
- return opts
+ opts.Freeze()
+ return opts
def main(argv):
- cros_build_lib.AssertInsideChroot()
+ cros_build_lib.AssertInsideChroot()
- opts = _ParseArgs(argv)
- try:
- toolchain.InstallToolchain(sysroot=opts.sysroot,
- toolchain=opts.toolchain,
- force=opts.force, configure=opts.configure)
- except (toolchain.Error, cros_build_lib.RunCommandError, ValueError) as e:
- cros_build_lib.Die(e)
+ opts = _ParseArgs(argv)
+ try:
+ toolchain.InstallToolchain(
+ sysroot=opts.sysroot,
+ toolchain=opts.toolchain,
+ force=opts.force,
+ configure=opts.configure,
+ )
+ except (toolchain.Error, cros_build_lib.RunCommandError, ValueError) as e:
+ cros_build_lib.Die(e)