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/sync_chrome.py b/scripts/sync_chrome.py
index c85ccfb..26b6185 100644
--- a/scripts/sync_chrome.py
+++ b/scripts/sync_chrome.py
@@ -16,63 +16,85 @@
def GetParser():
- """Creates the argparse parser."""
- parser = commandline.ArgumentParser(description=__doc__)
+ """Creates the argparse parser."""
+ parser = commandline.ArgumentParser(description=__doc__)
- version = parser.add_mutually_exclusive_group()
- version.add_argument('--tag', help='Sync to specified Chrome release',
- dest='version')
- version.add_argument('--revision', help='Sync to specified git revision',
- dest='version')
+ version = parser.add_mutually_exclusive_group()
+ version.add_argument(
+ "--tag", help="Sync to specified Chrome release", dest="version"
+ )
+ version.add_argument(
+ "--revision", help="Sync to specified git revision", dest="version"
+ )
- parser.add_argument('--internal', help='Sync internal version of Chrome',
- action='store_true', default=False)
- parser.add_argument('--reset', help='Revert local changes',
- action='store_true', default=False)
- parser.add_argument('--gclient', help=argparse.SUPPRESS, default=None)
- parser.add_argument('--gclient_template', help='Template gclient input file')
- parser.add_argument('--skip_cache', help='Skip using git cache',
- dest='use_cache', action='store_false')
- parser.add_argument('--git_cache_dir', type='path',
- help='Define explicit git cache.')
- parser.add_argument('chrome_root', help='Directory to sync chrome in')
+ parser.add_argument(
+ "--internal",
+ help="Sync internal version of Chrome",
+ action="store_true",
+ default=False,
+ )
+ parser.add_argument(
+ "--reset",
+ help="Revert local changes",
+ action="store_true",
+ default=False,
+ )
+ parser.add_argument("--gclient", help=argparse.SUPPRESS, default=None)
+ parser.add_argument(
+ "--gclient_template", help="Template gclient input file"
+ )
+ parser.add_argument(
+ "--skip_cache",
+ help="Skip using git cache",
+ dest="use_cache",
+ action="store_false",
+ )
+ parser.add_argument(
+ "--git_cache_dir", type="path", help="Define explicit git cache."
+ )
+ parser.add_argument("chrome_root", help="Directory to sync chrome in")
- return parser
+ return parser
def SyncChrome(gclient_path, options):
- """Sync new Chrome."""
- gclient.WriteConfigFile(gclient_path, options.chrome_root,
- options.internal, options.version,
- options.gclient_template, options.use_cache,
- git_cache_dir=options.git_cache_dir)
- try:
- gclient.Sync(gclient_path, options.chrome_root, reset=options.reset)
- except cros_build_lib.RunCommandError as e:
- cros_build_lib.Die(f'gclient sync exited {e.returncode}')
+ """Sync new Chrome."""
+ gclient.WriteConfigFile(
+ gclient_path,
+ options.chrome_root,
+ options.internal,
+ options.version,
+ options.gclient_template,
+ options.use_cache,
+ git_cache_dir=options.git_cache_dir,
+ )
+ try:
+ gclient.Sync(gclient_path, options.chrome_root, reset=options.reset)
+ except cros_build_lib.RunCommandError as e:
+ cros_build_lib.Die(f"gclient sync exited {e.returncode}")
def main(argv):
- parser = GetParser()
- options = parser.parse_args(argv)
+ parser = GetParser()
+ options = parser.parse_args(argv)
- if options.gclient == '':
- parser.error('--gclient can not be an empty string!')
- gclient_path = options.gclient or osutils.Which('gclient')
- if not gclient_path:
- gclient_path = os.path.join(constants.DEPOT_TOOLS_DIR, 'gclient')
+ if options.gclient == "":
+ parser.error("--gclient can not be an empty string!")
+ gclient_path = options.gclient or osutils.Which("gclient")
+ if not gclient_path:
+ gclient_path = os.path.join(constants.DEPOT_TOOLS_DIR, "gclient")
- try:
- if options.reset:
- # Revert any lingering local changes.
- gclient.Revert(gclient_path, options.chrome_root)
+ try:
+ if options.reset:
+ # Revert any lingering local changes.
+ gclient.Revert(gclient_path, options.chrome_root)
- SyncChrome(gclient_path, options)
- except cros_build_lib.RunCommandError:
- # If we have an error resetting, or syncing, we clobber, and fresh sync.
- logging.warning('Chrome checkout appears corrupt. Clobbering.')
- osutils.RmDir(options.chrome_root, ignore_missing=True, sudo=True)
- osutils.SafeMakedirsNonRoot(options.chrome_root)
- SyncChrome(gclient_path, options)
+ SyncChrome(gclient_path, options)
+ except cros_build_lib.RunCommandError:
+ # If we have an error resetting, or syncing, we clobber, and fresh sync.
+ logging.warning("Chrome checkout appears corrupt. Clobbering.")
+ osutils.RmDir(options.chrome_root, ignore_missing=True, sudo=True)
+ osutils.SafeMakedirsNonRoot(options.chrome_root)
+ SyncChrome(gclient_path, options)
- return 0
+ return 0