diff options
| author | Martin Fischer <martin@push-f.com> | 2025-03-09 11:13:20 +0100 | 
|---|---|---|
| committer | Martin Fischer <martin@push-f.com> | 2025-03-09 11:13:20 +0100 | 
| commit | 42c737aa1a7731170e8369482f96b557a1bd7a36 (patch) | |
| tree | 46e9555760dc8d9f688dcaf47b7f44d3945629db | |
| parent | 85e2cea63af8300af62575d3a7d4b0458cca53f6 (diff) | |
feat: make scripts support --help
| -rwxr-xr-x | find_archived_proposals_without_template.py | 9 | ||||
| -rwxr-xr-x | proposals.py | 5 | 
2 files changed, 14 insertions, 0 deletions
| diff --git a/find_archived_proposals_without_template.py b/find_archived_proposals_without_template.py index 50dbbd9..6424745 100755 --- a/find_archived_proposals_without_template.py +++ b/find_archived_proposals_without_template.py @@ -1,10 +1,14 @@  #!/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 @@ -12,6 +16,11 @@ 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( diff --git a/proposals.py b/proposals.py index 92f1c28..e16412f 100755 --- a/proposals.py +++ b/proposals.py @@ -1,4 +1,6 @@  #!/usr/bin/env python3 +"""Queries wiki.openstreetmap.org for proposals and outputs a JSON list of them to stdout.""" +import argparse  import html  import json  import sys @@ -14,6 +16,9 @@ OSMWIKI_ENDPOINT = 'https://wiki.openstreetmap.org/w/api.php'  def run(): +    arg_parser = argparse.ArgumentParser(description=__doc__) +    arg_parser.parse_args() +      res = requests.get(          OSMWIKI_ENDPOINT,          params=dict( | 
