diff options
author | lloyd <[email protected]> | 2014-01-06 22:37:44 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2014-01-06 22:37:44 +0000 |
commit | 24788a676642a77be7d8859d4835e496b348f155 (patch) | |
tree | 1cd2d9b2da0027ecd6bd8b3deac1086444d51fe3 /src/scripts | |
parent | da780fd47c206ff3d4b538682453ffc9dd034bca (diff) |
Add a script for combining version .rst files
Diffstat (limited to 'src/scripts')
-rwxr-xr-x | src/scripts/combine_relnotes.py | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/scripts/combine_relnotes.py b/src/scripts/combine_relnotes.py new file mode 100755 index 000000000..df6bd5168 --- /dev/null +++ b/src/scripts/combine_relnotes.py @@ -0,0 +1,60 @@ +#!/usr/bin/python + +import re +import sys + +def main(args = None): + if args is None: + args = sys.argv + + re_version = re.compile('Version (\d+\.\d+\.\d+), ([0-9]{4}-[0-9]{2}-[0-9]{2})$') + re_nyr = re.compile('Version (\d+\.\d+\.\d+), Not Yet Released$') + + version_contents = {} + version_date = {} + versions = [] + versions_nyr = [] + + for f in args[1:]: + contents = open(f).readlines() + + match = re_version.match(contents[0]) + + if match: + version = match.group(1) + date = match.group(2) + versions.append(version) + version_date[version] = date + else: + match = re_nyr.match(contents[0]) + version = match.group(1) + + versions_nyr.append(version) + if not match: + raise Exception('No version match for %s' % (f)) + + version_contents[version] = (''.join(contents)).strip() + + def make_label(v): + return ".. _v%s:\n" % (v.replace('.', '_')) + + print "Release Notes" + print "========================================" + print + + date_to_version = {} + for (v,d) in version_date.items(): + date_to_version.setdefault(d, []).append(v) + + if len(versions_nyr) > 0: + for v in versions_nyr: + print make_label(v) + print version_contents[v], "\n" + + for d in sorted(date_to_version.keys(), reverse=True): + for v in sorted(date_to_version[d]): + print make_label(v) + print version_contents[v], "\n" + +if __name__ == '__main__': + sys.exit(main()) |