diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2017-04-26 12:03:51 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2017-05-04 10:25:02 +0000 |
commit | 1f8f34167be8bede05f5442d9969caf055f3c031 (patch) | |
tree | 1d0c8465fd8b02785ca3e61e6f045418e9ec8f53 /scripts/gen-quip-0000.py | |
parent | 7fad692328ffa099e31d6d9a8d27d7aff796f655 (diff) |
Add site generation scripts
Things left for future work:
* Sort out a suitable host on which to publish this (QTQAINFRA-1211)
* Set up a routine site-publishing cron job (QTQAINFRA-1211)
* Make links of entries in some headers (QTQAINFRA-1212)
Task-number: QTQAINFRA-1173
Started-by: Louai Al-Khanji <louai.al-khanji@qt.io>
Change-Id: I7ee0c37e38cf30de52684ac80cb7848ec8712a0e
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'scripts/gen-quip-0000.py')
-rwxr-xr-x | scripts/gen-quip-0000.py | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/scripts/gen-quip-0000.py b/scripts/gen-quip-0000.py new file mode 100755 index 0000000..0f2ded9 --- /dev/null +++ b/scripts/gen-quip-0000.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# Copyright (C) 2017 The Qt Company Ltd. +# Contact: http://www.qt.io/licensing/ +# +# You may use this file under the terms of the CC0 license. +# See the file LICENSE.CC0 from this package for details. + +from email.parser import HeaderParser +from glob import glob +import os.path + +class RootQuip (dict): + def __init__(self, files): + parser = HeaderParser() + for quip in files: + with open(quip, 'r') as quipfp: + self[quip] = parser.parse(quipfp) + + def last_name(names): # tool function for owners; not a method + while names and names[-1].startswith('<') and names[-1].endswith('>'): + names.pop() + return names[-1] + + @staticmethod + def owners(authors, final=last_name): + return ', '.join(final(s) for s in (a.split() for a in authors.split(','))) + del last_name + + def quip_entries(self): + fmt = ' <tr><td>%4s</td><td><a href="quip-%04d.html">%04d</a></td><td>%s</td><td>%s</td></tr>' + for filename in sorted(self): + q = self[filename] + num = int(q['QUIP']) + yield fmt % (q['Type'][:4], num, num, q['Title'], self.owners(q['Author'])) + + preamble = """\ +QUIP: 0 +Title: QUIP Index +Author: Louai Al-Khanji, Edward Welbourne +Status: Active +Type: Informational +Created: 2016-09-16 +Post-History: 2017-03-15 + +QUIP Index +========== + +This QUIP contains the index of all finalized Qt User-Submitted +Improvement Proposals, known as QUIPs. A list of reviews of quip +module changes, including any QUIPs under development, can be found in +the code-review listing [0]_. + +The following QUIPs exist: + +.. raw:: html + + <table> + <tr><th>type</th><th>number</th><th>title</th><th>owners</th></tr> +""" + + endpiece = """\ + </table> + +.. [0] https://codereview.qt-project.org/#/q/project:meta/quips,n,z +""" + + def compose_body(self): + return self.preamble + '\n'.join(self.quip_entries()) + self.endpiece + +if __name__ == '__main__': + import sys + print RootQuip(sys.argv[1:]).compose_body() |