From 8acf8e8c910ddb245620543d6f4f01eafa3c651d Mon Sep 17 00:00:00 2001
From: Martin Fischer <martin@push-f.com>
Date: Thu, 14 Jul 2022 04:46:08 +0200
Subject: filter out stub proposals

---
 proposals.py | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/proposals.py b/proposals.py
index 356ceba..0345c77 100755
--- a/proposals.py
+++ b/proposals.py
@@ -42,6 +42,11 @@ def get_template_val(tpl, name):
 
 proposals = []
 
+
+def eprint(*args):
+    print(*args, file=sys.stderr)
+
+
 for page in find_proposals():
     page_title = page['title']
     text = page['revisions'][0]['slots']['main']['content']
@@ -51,7 +56,7 @@ for page in find_proposals():
     )
 
     if not proposal_page_templates:
-        print('{{Proposal Page}} not found in', page_title, file=sys.stderr)
+        eprint('{{Proposal Page}} not found in', page_title)
         continue
 
     for comment in doc.ifilter_comments():
@@ -60,14 +65,25 @@ for page in find_proposals():
 
     tpl = proposal_page_templates[0]
 
-    name = get_template_val(tpl, 'name')
-    if name:
-        name = html.unescape(name)
-
     status = get_template_val(tpl, 'status')
     if status:
         status = status.lower()
 
+    archived = doc.filter_templates(
+        matches=lambda t: t.name.matches('Archived proposal')
+    )
+
+    if not doc.filter_headings() and not archived:
+        if status in ('approved', 'rejected'):
+            eprint(f'WARNING no headings found for {status} proposal', page['title'])
+        else:
+            eprint('skipping stub', page['title'])
+            continue
+
+    name = get_template_val(tpl, 'name')
+    if name:
+        name = html.unescape(name)
+
     draft_start = get_template_val(tpl, 'draftStartDate')
     if draft_start in ('*', '-'):
         draft_start = None
-- 
cgit v1.2.3