Commit de0974fb authored by Chris Lamb's avatar Chris Lamb 💬

Run the black reformatter over edit-notes.

parent 76937501
...@@ -7,23 +7,28 @@ from rblib import remote ...@@ -7,23 +7,28 @@ from rblib import remote
from rblib import yamlfiles from rblib import yamlfiles
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--verbose', action='store_true') parser.add_argument("--verbose", action="store_true")
parser.add_argument('-f', '--fix-note', action='append', default=[]) parser.add_argument("-f", "--fix-note", action="append", default=[])
parser.add_argument('-r', '--remove-note', action='append', default=[]) parser.add_argument("-r", "--remove-note", action="append", default=[])
parser.add_argument('-a', '--add-note', action='append', default=[]) parser.add_argument("-a", "--add-note", action="append", default=[])
parser.add_argument('-v', '--take-version', action='store_true') parser.add_argument("-v", "--take-version", action="store_true")
parser.add_argument('-c', '--set-comment') parser.add_argument("-c", "--set-comment")
parser.add_argument('-b', '--add-bug', type=int, action='append', default=[]) parser.add_argument("-b", "--add-bug", type=int, action="append", default=[])
parser.add_argument('-d', '--fix-deterministic', action='store_true') parser.add_argument("-d", "--fix-deterministic", action="store_true")
parser.add_argument('-u', '--remove', dest='remove', action='store_true', parser.add_argument(
help='remove the whole note block') "-u",
parser.add_argument('packages', nargs='*') "--remove",
dest="remove",
action="store_true",
help="remove the whole note block",
)
parser.add_argument("packages", nargs="*")
args = parser.parse_args() args = parser.parse_args()
with open('issues.yml') as fd: with open("issues.yml") as fd:
issues = yaml.safe_load(fd) issues = yaml.safe_load(fd)
if __name__ == '__main__': if __name__ == "__main__":
to_fix = set(args.fix_note) to_fix = set(args.fix_note)
to_remove = set(args.remove_note) to_remove = set(args.remove_note)
to_fix.update(to_remove) to_fix.update(to_remove)
...@@ -34,12 +39,10 @@ if __name__ == '__main__': ...@@ -34,12 +39,10 @@ if __name__ == '__main__':
# Validate issues # Validate issues
for add in args.add_note: for add in args.add_note:
if add not in issues.keys(): if add not in issues.keys():
raise ValueError('{!r} is not a valid issue'.format(add)) raise ValueError("{!r} is not a valid issue".format(add))
if args.fix_deterministic: if args.fix_deterministic:
to_fix.update( to_fix.update(k for (k, v) in issues.items() if v.get("deterministic", False))
k for (k, v) in issues.items() if v.get('deterministic', False)
)
for package in args.packages or notes.keys(): for package in args.packages or notes.keys():
try: try:
...@@ -51,23 +54,27 @@ if __name__ == '__main__': ...@@ -51,23 +54,27 @@ if __name__ == '__main__':
print("package {} appears not to exist; skipping".format(package)) print("package {} appears not to exist; skipping".format(package))
continue continue
data = notes[package] = {'version': status['version']} data = notes[package] = {"version": status["version"]}
if args.take_version: if args.take_version:
data['version'] = testedpkgs[package]['version'] data["version"] = testedpkgs[package]["version"]
for fix in to_fix: for fix in to_fix:
if fix in to_remove or testedpkgs.get(package, {}).get('status', False) == 'reproducible': if (
package_issues = data.get('issues', []) fix in to_remove
or testedpkgs.get(package, {}).get("status", False) == "reproducible"
):
package_issues = data.get("issues", [])
if fix in package_issues: if fix in package_issues:
if args.verbose: if args.verbose:
print('https://reproducible.debian.net/{} seems to be fixed'.format(package)) print(
"https://reproducible.debian.net/{} seems to be fixed".format(
package
)
)
package_issues.remove(fix) package_issues.remove(fix)
for src, dst in ( for src, dst in ((args.add_bug, "bugs"), (args.add_note, "issues")):
(args.add_bug, 'bugs'),
(args.add_note, 'issues'),
):
for x in src: for x in src:
if dst not in data: if dst not in data:
data[dst] = [] data[dst] = []
...@@ -77,13 +84,13 @@ if __name__ == '__main__': ...@@ -77,13 +84,13 @@ if __name__ == '__main__':
data[dst].append(x) data[dst].append(x)
if args.set_comment: if args.set_comment:
data['comments'] = args.set_comment data["comments"] = args.set_comment
if args.remove: if args.remove:
for pkg in args.packages: for pkg in args.packages:
try: try:
notes.pop(pkg) notes.pop(pkg)
except KeyError: except KeyError:
print('W: {} is not in the notes, skipping removing'.format(pkg)) print("W: {} is not in the notes, skipping removing".format(pkg))
yamlfiles.write_out(notes) yamlfiles.write_out(notes)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment