1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

doc: fix flake8 in generate changelog script

This commit is contained in:
Alexandre Abadie 2018-04-27 15:15:09 +02:00
parent 31dff69867
commit 9001b165f6

View File

@ -10,6 +10,7 @@ from __future__ import print_function
import re
import sys
def generate_changelog(template_filename, changelog_filename, output_filename):
with open(template_filename) as template, \
open(changelog_filename) as changelog, \
@ -17,7 +18,6 @@ def generate_changelog(template_filename, changelog_filename, output_filename):
changelog_lines = []
release_title = re.compile(r"((RIOT-\d{4}\.\d{2} - Release Notes)|(Release 2013\.08))")
notes_template = re.compile(r"\[Notes\]")
first_title = True
title = 0
prev_newline = False
# Traverse changelog file line-wise
@ -36,15 +36,14 @@ def generate_changelog(template_filename, changelog_filename, output_filename):
elif release_title.match(line):
# if line contains a release title
release_match = re.search(r"(\d{4}\.\d{2})", line)
assert(release_match != None)
assert(release_match is not None)
# parse out release number
release = release_match.group(1)
title = "Release %s" % release
tag = "release-%s" % release.replace('.', '-')
# append as level 1 title with reference anchor tag
changelog_lines.append("# %s {#%s}\n" % (title ,tag))
changelog_lines.append("# %s {#%s}\n" % (title, tag))
title = True
first_title = False
else:
# append non-title log lines as verbatim (so notation is kept)
changelog_lines.append(" %s" % line)
@ -58,9 +57,9 @@ def generate_changelog(template_filename, changelog_filename, output_filename):
# just print the template line
print(line, file=output, end="")
if __name__ == "__main__":
if len(sys.argv) < 4:
print("usage %s <md template> <changelog> <output md>" % sys.argv[0], file=sys.stderr)
sys.exit(1)
generate_changelog(sys.argv[1], sys.argv[2], sys.argv[3])