1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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()
|