More black

Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
Nils Philippsen 2020-01-31 17:19:00 +01:00
parent fd7cb9c9e5
commit 34243a93bf
2 changed files with 32 additions and 28 deletions

View file

@ -19,14 +19,10 @@ def run_command(command, cwd=None):
""" """
output = None output = None
try: try:
output = subprocess.check_output( output = subprocess.check_output(command, cwd=cwd, stderr=subprocess.PIPE)
command, cwd=cwd, stderr=subprocess.PIPE
)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
_log.error( _log.error(
"Command `{}` return code: `{}`".format( "Command `{}` return code: `{}`".format(" ".join(command), e.returncode)
" ".join(command), e.returncode
)
) )
_log.error("stdout:\n-------\n{}".format(e.stdout)) _log.error("stdout:\n-------\n{}".format(e.stdout))
_log.error("stderr:\n-------\n{}".format(e.stderr)) _log.error("stderr:\n-------\n{}".format(e.stderr))
@ -58,19 +54,30 @@ def main(args):
repo_obj.checkout_tree( repo_obj.checkout_tree(
commit, commit,
strategy=pygit2.GIT_CHECKOUT_FORCE | pygit2.GIT_CHECKOUT_RECREATE_MISSING) strategy=pygit2.GIT_CHECKOUT_FORCE | pygit2.GIT_CHECKOUT_RECREATE_MISSING,
)
if os.path.exists(os.path.join(args[0], f"{name}.spec")): if os.path.exists(os.path.join(args[0], f"{name}.spec")):
try: try:
output = run_command([ output = run_command(
"rpm", "--qf", '%{name} %{version} %{release}\n', [
"--specfile", f"{name}.spec", "rpm",
], cwd=args[0]) "--qf",
"%{name} %{version} %{release}\n",
"--specfile",
f"{name}.spec",
],
cwd=args[0],
)
except Exception: except Exception:
continue continue
output = tuple( output = tuple(
output.decode('utf-8').strip().split('\n')[0].rsplit('.', 1)[0].split(' ') output.decode("utf-8")
.strip()
.split("\n")[0]
.rsplit(".", 1)[0]
.split(" ")
) )
nvr = '-'.join(output) nvr = "-".join(output)
if commit.parents: if commit.parents:
diff = repo_obj.diff(commit.parents[0], commit) diff = repo_obj.diff(commit.parents[0], commit)
@ -82,7 +89,7 @@ def main(args):
files_changed = [d.new_file.path for d in diff.deltas] files_changed = [d.new_file.path for d in diff.deltas]
ignore = True ignore = True
for filename in files_changed: for filename in files_changed:
if filename.endswith(('.spec', '.patch')): if filename.endswith((".spec", ".patch")):
ignore = False ignore = False
if not ignore: if not ignore:
data[output].append(commit) data[output].append(commit)
@ -96,16 +103,19 @@ def main(args):
last_commit = idx + 1 == len(data[nvr]) last_commit = idx + 1 == len(data[nvr])
commit_dt = datetime.datetime.utcfromtimestamp(commit.commit_time) commit_dt = datetime.datetime.utcfromtimestamp(commit.commit_time)
wrapper = textwrap.TextWrapper(width=75, subsequent_indent=" ") wrapper = textwrap.TextWrapper(width=75, subsequent_indent=" ")
message = wrapper.fill(commit.message.split('\n')[0].strip('- ')) message = wrapper.fill(commit.message.split("\n")[0].strip("- "))
if last_commit: if last_commit:
print(f"* {commit_dt.strftime('%a %b %d %Y')} {commit.author.name} <{commit.author.email}> - {nvr[1]}-{nvr[2]}") print(
f"* {commit_dt.strftime('%a %b %d %Y')} {commit.author.name} <{commit.author.email}> - {nvr[1]}-{nvr[2]}"
)
else: else:
print(f"* {commit_dt.strftime('%a %b %d %Y')} {commit.author.name} <{commit.author.email}>") print(
f"* {commit_dt.strftime('%a %b %d %Y')} {commit.author.name} <{commit.author.email}>"
)
print("- %s" % message) print("- %s" % message)
print() print()
if __name__ == "__main__":
if __name__ == '__main__':
main(sys.argv[1:]) main(sys.argv[1:])

View file

@ -15,14 +15,10 @@ def run_command(command, cwd=None):
""" """
output = None output = None
try: try:
output = subprocess.check_output( output = subprocess.check_output(command, cwd=cwd, stderr=subprocess.PIPE)
command, cwd=cwd, stderr=subprocess.PIPE
)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
_log.error( _log.error(
"Command `{}` return code: `{}`".format( "Command `{}` return code: `{}`".format(" ".join(command), e.returncode)
" ".join(command), e.returncode
)
) )
_log.error("stdout:\n-------\n{}".format(e.stdout)) _log.error("stdout:\n-------\n{}".format(e.stdout))
_log.error("stderr:\n-------\n{}".format(e.stderr)) _log.error("stderr:\n-------\n{}".format(e.stderr))
@ -49,9 +45,7 @@ def main(args):
cmd = f"koji list-builds --package={args.package} --state=COMPLETE -r --quiet" cmd = f"koji list-builds --package={args.package} --state=COMPLETE -r --quiet"
rows = run_command(cmd.split()).decode("utf-8") rows = run_command(cmd.split()).decode("utf-8")
builds = [ builds = [row.strip().split()[0] for row in rows.split("\n") if row.strip()]
row.strip().split()[0] for row in rows.split("\n") if row.strip()
]
n_builds = 1 n_builds = 1
last_build = None last_build = None
nv = None nv = None