Formatting update for build script

Using `black` formatter for `fuchsia_upload.py`

Change-Id: I05be0daaf219f9a71ce2b66cada9715e27bcce50
Reviewed-on: https://turquoise-internal-review.googlesource.com/c/third_party/u-boot/+/1032610
Reviewed-by: David Pursell <dpursell@google.com>
GitOrigin-RevId: af1e671ecee0b6fd982e74bde2d0c43393693877
diff --git a/fuchsia_upload.py b/fuchsia_upload.py
index 920d547..d8fc2a9 100755
--- a/fuchsia_upload.py
+++ b/fuchsia_upload.py
@@ -29,16 +29,23 @@
 
 _MY_DIR = os.path.dirname(__file__)
 
-_LICENSE_SEPARATOR = ('\n===================================\n\n')
+_LICENSE_SEPARATOR = "\n===================================\n\n"
 # Explicitly enumerate known license files so that if a new one comes in,
 # the script will fail and notify us. Once the new file has been reviewed and
 # approved we can add it here.
-_KNOWN_LICENSE_FILES = ('bsd-2-clause.txt', 'bsd-3-clause.txt', 'eCos-2.0.txt',
-                        'gpl-2.0.txt', 'ibm-pibs.txt', 'isc.txt',
-                        'lgpl-2.0.txt', 'lgpl-2.1.txt')
+_KNOWN_LICENSE_FILES = (
+    "bsd-2-clause.txt",
+    "bsd-3-clause.txt",
+    "eCos-2.0.txt",
+    "gpl-2.0.txt",
+    "ibm-pibs.txt",
+    "isc.txt",
+    "lgpl-2.0.txt",
+    "lgpl-2.1.txt",
+)
 # Files in the licenses dir that are informational only and don't need to be
 # included in the license dump.
-_INFORMATIONAL_LICENSE_FILES = ('Exceptions', 'README')
+_INFORMATIONAL_LICENSE_FILES = ("Exceptions", "README")
 
 _BUILD_SCRIPT = os.path.join(_MY_DIR, "build_uboot_vim3_zircon.sh")
 
@@ -68,10 +75,10 @@
         FileExistsError if an unexpected license file was found.
     """
     licenses = []
-    license_dir = os.path.join(_MY_DIR, 'Licenses')
+    license_dir = os.path.join(_MY_DIR, "Licenses")
 
     def _add_license(name: str):
-        with open(os.path.join(license_dir, name), 'r') as f:
+        with open(os.path.join(license_dir, name), "r") as f:
             contents = f.read()
             # No need to duplicate licenses if they're the exact same.
             if contents not in licenses:
@@ -84,7 +91,7 @@
         elif name in _INFORMATIONAL_LICENSE_FILES:
             pass
         else:
-            raise FileExistsError(f'Unknown u-boot license file: {name}')
+            raise FileExistsError(f"Unknown u-boot license file: {name}")
 
     return _LICENSE_SEPARATOR.join(licenses)
 
@@ -106,11 +113,9 @@
     """
 
     def git(command):
-        return subprocess.run(["git"] + command,
-                              cwd=dir,
-                              check=True,
-                              capture_output=True,
-                              text=True).stdout.strip()
+        return subprocess.run(
+            ["git"] + command, cwd=dir, check=True, capture_output=True, text=True
+        ).stdout.strip()
 
     # Update the local repo.
     git(["fetch"])
@@ -119,8 +124,7 @@
     head_revision = git(["rev-parse", "HEAD"])
     upstream_revision = git(["rev-parse", upstream_branch])
     if head_revision != upstream_revision:
-        raise ValueError(
-            f"HEAD {head_revision} != upstream {upstream_revision}")
+        raise ValueError(f"HEAD {head_revision} != upstream {upstream_revision}")
 
     # Check for any uncommitted file changes. This will print the name of
     # any uncommitted files, so empty string means no local changes.
@@ -152,7 +156,8 @@
         revision = "vim3"
 
     # http://go/copybara-reference.
-    contents = textwrap.dedent(f"""\
+    contents = textwrap.dedent(
+        f"""\
         core.workflow(
             name = "default",
             origin = git.origin(
@@ -168,7 +173,8 @@
                 default = "Fuchsia firmware team <tq-firmware-team@google.com>"
             ),
         )
-        """)
+        """
+    )
 
     return contents
 
@@ -189,31 +195,32 @@
         revision = "__local_dirty__"
 
     metadata_files = {
-        "OWNERS":
-            "fuchsia-firmware@google.com",
-        "manifest.json":
-            json.dumps({_REPO_NAME: revision}, indent=2, sort_keys=True),
-        "LICENSE":
-            license_file_contents()
+        "OWNERS": "fuchsia-firmware@google.com",
+        "manifest.json": json.dumps({_REPO_NAME: revision}, indent=2, sort_keys=True),
+        "LICENSE": license_file_contents(),
     }
 
     for name, contents in metadata_files.items():
         with open(os.path.join(_CIPD_FILES_DIR, name), "w") as f:
             f.write(contents)
 
-    shutil.copyfile(_BUILD_ARTIFACT_PATH,
-                    os.path.join(_CIPD_FILES_DIR, _BUILD_ARTIFACT_NAME))
+    shutil.copyfile(
+        _BUILD_ARTIFACT_PATH, os.path.join(_CIPD_FILES_DIR, _BUILD_ARTIFACT_NAME)
+    )
 
     # Create CIPD yaml file
     with open(_CIPD_YAML_FILE_NAME, "w") as cipd_yaml_file:
         logging.info("Writing CIPD yaml file: `%s`", _CIPD_YAML_FILE_NAME)
-        cipd_yaml_file.write(textwrap.dedent(
-            f"""\
+        cipd_yaml_file.write(
+            textwrap.dedent(
+                f"""\
                 package: {_CIPD_PACKAGE}
                 description: vim3 firmware image
                 install_mode: copy
                 data:
-            """))
+            """
+            )
+        )
 
         cipd_yaml_file.write(f"  - file: {_BUILD_ARTIFACT_NAME}\n")
         for name in metadata_files:
@@ -236,19 +243,29 @@
         logging.warning("No source revision given, using 'vim3' ToT")
         revision = "vim3"
 
-    contents = json.dumps([{
-        "path": os.path.relpath(_CIPD_YAML_FILE_NAME, _MY_DIR),
-        "tags": {_REPO_NAME: revision}
-        }], indent = 4, sort_keys = True)
+    contents = json.dumps(
+        [
+            {
+                "path": os.path.relpath(_CIPD_YAML_FILE_NAME, _MY_DIR),
+                "tags": {_REPO_NAME: revision},
+            }
+        ],
+        indent=4,
+        sort_keys=True,
+    )
 
     with open(filename, "w") as yaml_manifest_file:
         logging.info("Writing YAML file: `%s`", filename)
         yaml_manifest_file.write(contents)
 
 
-def publish_source(revision: Optional[str], copybara_path: str,
-                   last_rev: Optional[str], dry_run: bool,
-                   push_justification: str):
+def publish_source(
+    revision: Optional[str],
+    copybara_path: str,
+    last_rev: Optional[str],
+    dry_run: bool,
+    push_justification: str,
+):
     """Publishes this source to the public repo.
 
     Args:
@@ -271,12 +288,17 @@
         with open(config_path, "w") as config_file:
             config_file.write(config)
 
-        command = [copybara_path, config_path, "--git-push-option", "push-justification=" + push_justification]
+        command = [
+            copybara_path,
+            config_path,
+            "--git-push-option",
+            "push-justification=" + push_justification,
+        ]
         if last_rev:
             command += ["--last-rev", last_rev]
         if dry_run:
             command.append("--dry-run")
-        logging.info("Copybara command: `%s`", ' '.join(command))
+        logging.info("Copybara command: `%s`", " ".join(command))
 
         # Let stdout/sterr through to the console since this may take a while.
         subprocess.run(command, check=True)
@@ -284,29 +306,33 @@
 
 def _parse_args() -> argparse.Namespace:
     parser = argparse.ArgumentParser(
-        description=__doc__,
-        formatter_class=argparse.RawDescriptionHelpFormatter)
+        description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
+    )
 
-    parser.add_argument("--cipd",
-                        default="cipd",
-                        help="Path to CIPD tool; looks on $PATH by default")
-    parser.add_argument("--copybara",
-                        default=_COPYBARA_PATH,
-                        help=f"Path to copybara tool; default {_COPYBARA_PATH}")
-    parser.add_argument("--dry-run",
-                        action="store_true",
-                        help="Don't upload anything")
-    parser.add_argument("--cipd-yaml-manifest",
-                        default="",
-                        help="Write YAML manifest for CIPD in specified file")
+    parser.add_argument(
+        "--cipd", default="cipd", help="Path to CIPD tool; looks on $PATH by default"
+    )
+    parser.add_argument(
+        "--copybara",
+        default=_COPYBARA_PATH,
+        help=f"Path to copybara tool; default {_COPYBARA_PATH}",
+    )
+    parser.add_argument("--dry-run", action="store_true", help="Don't upload anything")
+    parser.add_argument(
+        "--cipd-yaml-manifest",
+        default="",
+        help="Write YAML manifest for CIPD in specified file",
+    )
     parser.add_argument(
         "--last-rev",
         help="The last source revision that was released."
-        " Only use this on the first run to tell copybara where to start.")
+        " Only use this on the first run to tell copybara where to start.",
+    )
     parser.add_argument(
         "--push-justification",
         default="b/302031093",
-        help="BugID for git push justification.")
+        help="BugID for git push justification.",
+    )
 
     return parser.parse_args()
 
@@ -325,7 +351,9 @@
         else:
             raise
 
-    publish_source(revision, args.copybara, args.last_rev, args.dry_run, args.push_justification)
+    publish_source(
+        revision, args.copybara, args.last_rev, args.dry_run, args.push_justification
+    )
     build()
 
     if args.cipd_yaml_manifest:
@@ -334,5 +362,5 @@
     return 0
 
 
-if __name__ == '__main__':
+if __name__ == "__main__":
     sys.exit(_main())