From 8388b50e1a16483edcb508bcd7a513bf55b50391 Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sat, 22 Mar 2025 21:16:42 +0100 Subject: refactor: improve parse_proposal signature --- osm_proposals/proposals.py | 14 ++++++++------ 1 file 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') -- cgit v1.2.3