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/cros_generate_os_release.py b/scripts/cros_generate_os_release.py
index 6db6649..83a7b16 100644
--- a/scripts/cros_generate_os_release.py
+++ b/scripts/cros_generate_os_release.py
@@ -12,67 +12,72 @@
def GenerateOsRelease(root, default_params=None):
- """Adds contents of /etc/os-release.d into /etc/os-release
+ """Adds contents of /etc/os-release.d into /etc/os-release
- Args:
- root: path to the root directory where os-release should be genereated.
- default_params: a dict of os-release parameters that should be added
- if not already set.
- """
- os_release_path = os.path.join(root, 'etc', 'os-release')
- os_released_path = os.path.join(root, 'etc', 'os-release.d')
+ Args:
+ root: path to the root directory where os-release should be genereated.
+ default_params: a dict of os-release parameters that should be added
+ if not already set.
+ """
+ os_release_path = os.path.join(root, "etc", "os-release")
+ os_released_path = os.path.join(root, "etc", "os-release.d")
- mapping = {}
- if os.path.exists(os_release_path):
- content = osutils.ReadFile(os_release_path)
+ mapping = {}
+ if os.path.exists(os_release_path):
+ content = osutils.ReadFile(os_release_path)
- for line in content.splitlines():
- if line.startswith('#'):
- continue
+ for line in content.splitlines():
+ if line.startswith("#"):
+ continue
- key_value = line.split('=', 1)
- if len(key_value) != 2:
- cros_build_lib.Die('Malformed line in /etc/os-release')
+ key_value = line.split("=", 1)
+ if len(key_value) != 2:
+ cros_build_lib.Die("Malformed line in /etc/os-release")
- mapping[key_value[0]] = key_value[1].strip()
+ mapping[key_value[0]] = key_value[1].strip()
- if os.path.isdir(os_released_path):
- for filepath in os.listdir(os_released_path):
- key = os.path.basename(filepath)
- if key in mapping:
- cros_build_lib.Die('key %s defined in /etc/os-release.d but already '
- 'defined in /etc/os-release.' % key)
- mapping[key] = osutils.ReadFile(os.path.join(os_released_path,
- filepath)).strip('\n')
+ if os.path.isdir(os_released_path):
+ for filepath in os.listdir(os_released_path):
+ key = os.path.basename(filepath)
+ if key in mapping:
+ cros_build_lib.Die(
+ "key %s defined in /etc/os-release.d but already "
+ "defined in /etc/os-release." % key
+ )
+ mapping[key] = osutils.ReadFile(
+ os.path.join(os_released_path, filepath)
+ ).strip("\n")
- if default_params:
- for key, value in default_params.items():
- mapping.setdefault(key, value)
+ if default_params:
+ for key, value in default_params.items():
+ mapping.setdefault(key, value)
- osrelease_content = '\n'.join([k + '=' + mapping[k] for k in mapping])
- osrelease_content += '\n'
- osutils.WriteFile(os_release_path, osrelease_content)
+ osrelease_content = "\n".join([k + "=" + mapping[k] for k in mapping])
+ osrelease_content += "\n"
+ osutils.WriteFile(os_release_path, osrelease_content)
+
def main(argv):
- parser = commandline.ArgumentParser(description=__doc__)
- parser.add_argument('--root', type='path', required=True,
- help='sysroot of the board')
- parser.add_argument('--version', help='The image version string.')
- parser.add_argument('--build_id', help='The image build ID string.')
- options = parser.parse_args(argv)
- options.Freeze()
+ parser = commandline.ArgumentParser(description=__doc__)
+ parser.add_argument(
+ "--root", type="path", required=True, help="sysroot of the board"
+ )
+ parser.add_argument("--version", help="The image version string.")
+ parser.add_argument("--build_id", help="The image build ID string.")
+ options = parser.parse_args(argv)
+ options.Freeze()
- default_params = {
- 'NAME': 'Chromium OS',
- 'ID': 'chromiumos',
- 'HOME_URL': 'https://www.chromium.org/chromium-os',
- 'BUG_REPORT_URL': 'https://crbug.com/new',
- }
+ default_params = {
+ "NAME": "Chromium OS",
+ "ID": "chromiumos",
+ "HOME_URL": "https://www.chromium.org/chromium-os",
+ "BUG_REPORT_URL": "https://crbug.com/new",
+ }
- if options.version:
- default_params['VERSION'] = options.version
- default_params['VERSION_ID'] = options.version
- if options.build_id:
- default_params['BUILD_ID'] = options.build_id
+ if options.version:
+ default_params["VERSION"] = options.version
+ default_params["VERSION_ID"] = options.version
+ if options.build_id:
+ default_params["BUILD_ID"] = options.build_id
- GenerateOsRelease(options.root, default_params)
+ GenerateOsRelease(options.root, default_params)