summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2025-03-22 21:16:42 +0100
committerMartin Fischer <martin@push-f.com>2025-03-23 20:54:46 +0100
commit8388b50e1a16483edcb508bcd7a513bf55b50391 (patch)
tree248a60702836428ef96c73a5dff9cd235607f358
parentd363099b6093e4f204dda43676eb16ab2aa4605d (diff)
refactor: improve parse_proposal signature
-rwxr-xr-xosm_proposals/proposals.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/osm_proposals/proposals.py b/osm_proposals/proposals.py
index c111699..1bb1f14 100755
--- a/osm_proposals/proposals.py
+++ b/osm_proposals/proposals.py
@@ -42,7 +42,11 @@ def run():
rvprop='content',
rvslots='main',
):
- proposal = parse_proposal(page, langs)
+ proposal = parse_proposal(
+ page_title=page['title'],
+ text=page['revisions'][0]['slots']['main']['content'],
+ langs=langs,
+ )
if proposal:
proposals.append(proposal)
@@ -91,9 +95,7 @@ def is_stub(doc):
return False
-def parse_proposal(page: dict, langs: Container[str]) -> dict | None:
- page_title = page['title']
- text = page['revisions'][0]['slots']['main']['content']
+def parse_proposal(page_title: str, text: str, langs: Container[str]) -> dict | None:
doc = mwparserfromhell.parse(text)
proposal_page_templates = doc.filter_templates(
matches=lambda t: t.name.matches('Proposal page')
@@ -116,9 +118,9 @@ def parse_proposal(page: dict, langs: Container[str]) -> dict | None:
if is_stub(doc):
if status in ('approved', 'rejected'):
- eprint(f'WARNING {status} proposal is a stub', page['title'])
+ eprint(f'WARNING {status} proposal is a stub', page_title)
else:
- eprint('skipping stub', page['title'])
+ eprint('skipping stub', page_title)
return None
name = get_template_val(tpl, 'name')