forked from lahwaacz/wiki-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
find-closed-discussions.py
39 lines (29 loc) · 1.08 KB
/
find-closed-discussions.py
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
#! /usr/bin/env python3
from ws.client import API
from ws.db.database import Database
from ws.utils.OrderedSet import OrderedSet
def main(api, db):
db.sync_with_api(api)
db.sync_latest_revisions_content(api)
db.update_parser_cache()
namespaces = ["1", "5", "11", "13", "15"]
talks = OrderedSet()
for ns in namespaces:
for page in db.query(generator="allpages", gapnamespace=ns, prop="sections", secprop={"title"}):
for section in page.get("sections", []):
if section["title"].startswith("<s>") and section["title"].endswith("</s>"):
talks.add(page["title"])
for talk in talks:
print("* [[{}]]".format(talk))
if __name__ == "__main__":
import ws.config
import ws.logging
argparser = ws.config.getArgParser(description="Find closed discussions")
API.set_argparser(argparser)
Database.set_argparser(argparser)
args = argparser.parse_args()
# set up logging
ws.logging.init(args)
api = API.from_argparser(args)
db = Database.from_argparser(args)
main(api, db)