summaryrefslogtreecommitdiff
path: root/find_archived_proposals_without_template.py
blob: 6424745df4d60bafee39aeb67805b28890a6eeb7 (plain)
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
#!/usr/bin/env python3
"""
Queries wiki.openstreetmap.org for archived proposal pages without the {{Proposal page}} template.

Sometimes when archiving a page people accidentally also replace the
{{Proposal page}} template, which however means that proposal.py
won't find the page anymore. This script lists such pages so that the
template can be manually restored.
"""
import argparse

import pywikiapi
import mwparserfromhell

OSMWIKI_ENDPOINT = 'https://wiki.openstreetmap.org/w/api.php'


def run():
    arg_parser = argparse.ArgumentParser(
        description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
    )
    arg_parser.parse_args()

    osmwiki = pywikiapi.Site(OSMWIKI_ENDPOINT)

    for page in osmwiki.query_pages(
        generator='categorymembers',
        gcmtitle='Category:Archived proposals',
        gcmlimit='max',
        prop='templates',
        tltemplates='Template:Proposal page',
    ):
        if not 'templates' in page:
            print(page['title'])


if __name__ == "__main__":
    run()