treewide: lint and format
Run all the latest linters and formatters from openbmc-build-scripts.
These were all robotically generated except for fixes due to
markdownlint warnings.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: If16d2fd802a2d452234d8b56b41e79d030138a6b
diff --git a/openbmc-autobump/openbmc-autobump.py b/openbmc-autobump/openbmc-autobump.py
index 4531b61..ea6e2b8 100755
--- a/openbmc-autobump/openbmc-autobump.py
+++ b/openbmc-autobump/openbmc-autobump.py
@@ -18,55 +18,56 @@
import argparse
import os
-import sh
import sys
-git = sh.git.bake('--no-pager')
+import sh
+
+git = sh.git.bake("--no-pager")
def log(msg, args):
if args.noisy:
- sys.stderr.write('{}\n'.format(msg))
+ sys.stderr.write("{}\n".format(msg))
def git_clone_or_reset(local_name, remote, args):
if not os.path.exists(local_name):
- log('cloning into {}...'.format(local_name), args)
+ log("cloning into {}...".format(local_name), args)
git.clone(remote, local_name)
else:
- log('{} exists, updating...'.format(local_name), args)
+ log("{} exists, updating...".format(local_name), args)
git.fetch(_cwd=local_name)
- git.reset('--hard', 'FETCH_HEAD', _cwd=local_name)
+ git.reset("--hard", "FETCH_HEAD", _cwd=local_name)
def extract_project_from_uris(uris):
# remove SRC_URI = and quotes (does not handle escaped quotes)
uris = uris.split('"')[1]
for uri in uris.split():
- if 'github.com/openbmc' not in uri:
+ if "github.com/openbmc" not in uri:
continue
# remove fetcher arguments
- uri = uri.split(';')[0]
+ uri = uri.split(";")[0]
# the project is the right-most path segment
- return uri.split('/')[-1].replace('.git', '')
+ return uri.split("/")[-1].replace(".git", "")
return None
def extract_sha_from_recipe(recipe):
with open(recipe) as fp:
- uris = ''
+ uris = ""
project = None
sha = None
for line in fp:
line = line.rstrip()
- if 'SRCREV' in line:
- sha = line.split('=')[-1].replace('"', '').strip()
- elif not project and uris or '_URI' in line:
- uris += line.split('\\')[0]
- if '\\' not in line:
+ if "SRCREV" in line:
+ sha = line.split("=")[-1].replace('"', "").strip()
+ elif not project and uris or "_URI" in line:
+ uris += line.split("\\")[0]
+ if "\\" not in line:
# In uris we've gathered a complete (possibly multi-line)
# assignment to a bitbake variable that ends with _URI.
# Try to pull an OpenBMC project out of it.
@@ -74,33 +75,33 @@
if project is None:
# We didn't find a project. Unset uris and look for
# another bitbake variable that ends with _URI.
- uris = ''
+ uris = ""
if project and sha:
return (project, sha)
- raise RuntimeError('No SRCREV or URI found in {}'.format(recipe))
+ raise RuntimeError("No SRCREV or URI found in {}".format(recipe))
def find_candidate_recipes(meta, args):
remote_fmt_args = (args.ssh_config_host, meta)
- remote = 'ssh://{}/openbmc/{}'.format(*remote_fmt_args)
+ remote = "ssh://{}/openbmc/{}".format(*remote_fmt_args)
try:
git_clone_or_reset(meta, remote, args)
except sh.ErrorReturnCode as e:
- log('{}'.format(e), args)
+ log("{}".format(e), args)
return []
- match_suffixes = ('bb', 'bbclass', 'inc')
- pathspecs = ('*.{}'.format(x) for x in match_suffixes)
- grep_args = ('-l', '-e', '_URI', '--and', '-e', 'github.com/openbmc')
+ match_suffixes = ("bb", "bbclass", "inc")
+ pathspecs = ("*.{}".format(x) for x in match_suffixes)
+ grep_args = ("-l", "-e", "_URI", "--and", "-e", "github.com/openbmc")
grep_args = (*grep_args, *pathspecs)
try:
- return git.grep(*grep_args, _cwd=meta).stdout.decode('utf-8').split()
+ return git.grep(*grep_args, _cwd=meta).stdout.decode("utf-8").split()
except sh.ErrorReturnCode_1:
pass
except sh.ErrorReturnCode as e:
- log('{}'.format(e), args)
+ log("{}".format(e), args)
return []
@@ -114,50 +115,50 @@
project_name, recipe_sha = extract_sha_from_recipe(full_recipe_path)
remote_fmt_args = (args.ssh_config_host, project_name)
- remote = 'ssh://{}/openbmc/{}'.format(*remote_fmt_args)
- ls_remote_args = [remote, 'refs/heads/{}'.format(args.branch)]
+ remote = "ssh://{}/openbmc/{}".format(*remote_fmt_args)
+ ls_remote_args = [remote, "refs/heads/{}".format(args.branch)]
try:
- project_sha = git('ls-remote', *ls_remote_args)
- project_sha = project_sha.stdout.decode('utf-8').split()[0]
+ project_sha = git("ls-remote", *ls_remote_args)
+ project_sha = project_sha.stdout.decode("utf-8").split()[0]
except sh.ErrorReturnCode as e:
- log('{}'.format(e), args)
+ log("{}".format(e), args)
continue
if project_sha == recipe_sha:
message_args = (recipe_basename, recipe_sha[:10])
- print('{} is up to date ({})'.format(*message_args))
+ print("{} is up to date ({})".format(*message_args))
continue
- change_id = 'autobump {} {} {}'.format(recipe, recipe_sha, project_sha)
- hash_object_args = ['-t', 'blob', '--stdin']
- change_id = git(sh.echo(change_id), 'hash-object', *hash_object_args)
- change_id = 'I{}'.format(change_id.strip())
+ change_id = "autobump {} {} {}".format(recipe, recipe_sha, project_sha)
+ hash_object_args = ["-t", "blob", "--stdin"]
+ change_id = git(sh.echo(change_id), "hash-object", *hash_object_args)
+ change_id = "I{}".format(change_id.strip())
- query_args = ['query', 'change:{}'.format(change_id)]
+ query_args = ["query", "change:{}".format(change_id)]
gerrit_query_result = args.gerrit(*query_args)
- gerrit_query_result = gerrit_query_result.stdout.decode('utf-8')
+ gerrit_query_result = gerrit_query_result.stdout.decode("utf-8")
- if (change_id in gerrit_query_result):
+ if change_id in gerrit_query_result:
message_args = (recipe_basename, change_id)
- print('{} {} already exists'.format(*message_args))
+ print("{} {} already exists".format(*message_args))
continue
message_args = (recipe_basename, recipe_sha[:10], project_sha[:10])
- print('{} updating from {} to {}'.format(*message_args))
+ print("{} updating from {} to {}".format(*message_args))
remote_args = (args.ssh_config_host, project_name)
- remote = 'ssh://{}/openbmc/{}'.format(*remote_args)
+ remote = "ssh://{}/openbmc/{}".format(*remote_args)
git_clone_or_reset(project_name, remote, args)
try:
- revlist = '{}..{}'.format(recipe_sha, project_sha)
+ revlist = "{}..{}".format(recipe_sha, project_sha)
shortlog = git.shortlog(revlist, _cwd=project_name)
- shortlog = shortlog.stdout.decode('utf-8')
+ shortlog = shortlog.stdout.decode("utf-8")
except sh.ErrorReturnCode as e:
- log('{}'.format(e), args)
+ log("{}".format(e), args)
continue
- reset_args = ['--hard', 'origin/{}'.format(args.branch)]
+ reset_args = ["--hard", "origin/{}".format(args.branch)]
git.reset(*reset_args, _cwd=meta)
recipe_content = None
@@ -165,28 +166,28 @@
recipe_content = fd.read()
recipe_content = recipe_content.replace(recipe_sha, project_sha)
- with open(full_recipe_path, 'w') as fd:
+ with open(full_recipe_path, "w") as fd:
fd.write(recipe_content)
git.add(recipe, _cwd=meta)
commit_summary_args = (project_name, recipe_sha[:10], project_sha[:10])
- commit_msg = '{}: srcrev bump {}..{}'.format(*commit_summary_args)
- commit_msg += '\n\n{}'.format(shortlog)
- commit_msg += '\n\nChange-Id: {}'.format(change_id)
+ commit_msg = "{}: srcrev bump {}..{}".format(*commit_summary_args)
+ commit_msg += "\n\n{}".format(shortlog)
+ commit_msg += "\n\nChange-Id: {}".format(change_id)
- git.commit(sh.echo(commit_msg), '-s', '-F', '-', _cwd=meta)
+ git.commit(sh.echo(commit_msg), "-s", "-F", "-", _cwd=meta)
push_args = [
- 'origin',
- 'HEAD:refs/for/{}%topic=autobump'.format(args.branch)
+ "origin",
+ "HEAD:refs/for/{}%topic=autobump".format(args.branch),
]
if not args.dry_run:
git.push(*push_args, _cwd=meta)
def main():
- app_description = '''OpenBMC bitbake recipe bumping tool.
+ app_description = """OpenBMC bitbake recipe bumping tool.
Find bitbake metadata files (recipes) that use the git fetcher
and check the project repository for newer revisions.
@@ -194,37 +195,52 @@
Generate commits that update bitbake metadata files with SRCREV.
Push generated commits to the OpenBMC Gerrit instance for review.
- '''
+ """
parser = argparse.ArgumentParser(
description=app_description,
- formatter_class=argparse.RawDescriptionHelpFormatter)
+ formatter_class=argparse.RawDescriptionHelpFormatter,
+ )
- parser.set_defaults(branch='master')
+ parser.set_defaults(branch="master")
parser.add_argument(
- '-d', '--dry-run', dest='dry_run', action='store_true',
- help='perform a dry run only')
+ "-d",
+ "--dry-run",
+ dest="dry_run",
+ action="store_true",
+ help="perform a dry run only",
+ )
parser.add_argument(
- '-m', '--meta-repository', dest='meta_repository', action='append',
- help='meta repository to check for updates')
+ "-m",
+ "--meta-repository",
+ dest="meta_repository",
+ action="append",
+ help="meta repository to check for updates",
+ )
parser.add_argument(
- '-v', '--verbose', dest='noisy', action='store_true',
- help='enable verbose status messages')
+ "-v",
+ "--verbose",
+ dest="noisy",
+ action="store_true",
+ help="enable verbose status messages",
+ )
parser.add_argument(
- 'ssh_config_host', metavar='SSH_CONFIG_HOST_ENTRY',
- help='SSH config host entry for Gerrit connectivity')
+ "ssh_config_host",
+ metavar="SSH_CONFIG_HOST_ENTRY",
+ help="SSH config host entry for Gerrit connectivity",
+ )
args = parser.parse_args()
- setattr(args, 'gerrit', sh.ssh.bake(args.ssh_config_host, 'gerrit'))
+ setattr(args, "gerrit", sh.ssh.bake(args.ssh_config_host, "gerrit"))
- metas = getattr(args, 'meta_repository')
+ metas = getattr(args, "meta_repository")
if metas is None:
- metas = args.gerrit('ls-projects', '-m', 'meta-')
- metas = metas.stdout.decode('utf-8').split()
+ metas = args.gerrit("ls-projects", "-m", "meta-")
+ metas = metas.stdout.decode("utf-8").split()
metas = [os.path.split(x)[-1] for x in metas]
for meta in metas:
find_and_process_bumps(meta, args)
-if __name__ == '__main__':
+if __name__ == "__main__":
sys.exit(0 if main() else 1)