#!/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 = ' %4s%04d%s%s' 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 """ endpiece = """\
typenumbertitleowners
.. [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()