summaryrefslogtreecommitdiff
path: root/doc/postprocess.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2020-03-08 19:54:38 -0600
committerGitHub <noreply@github.com>2020-03-08 19:54:38 -0600
commit9da90debf54029a50502fd759c8de56f2dc47129 (patch)
tree600011e9b1a4f14f53208827d72f7c6eb49e3ae7 /doc/postprocess.py
parent105e175a7708a05886d06a24ed2b60bdd6cf329c (diff)
parenta7af9cc2578cdc128e662d163552fcb22da3c496 (diff)
downloadnumpy-9da90debf54029a50502fd759c8de56f2dc47129.tar.gz
Merge pull request #15702 from mwtoews/optparse
MAINT: Replace optparse with argparse for 'doc' and 'tools' scripts
Diffstat (limited to 'doc/postprocess.py')
-rwxr-xr-xdoc/postprocess.py21
1 files changed, 7 insertions, 14 deletions
diff --git a/doc/postprocess.py b/doc/postprocess.py
index 309161bc0..3e066d22e 100755
--- a/doc/postprocess.py
+++ b/doc/postprocess.py
@@ -1,27 +1,20 @@
#!/usr/bin/env python3
"""
-%prog MODE FILES...
-
Post-processes HTML and Latex files output by Sphinx.
-MODE is either 'html' or 'tex'.
-
"""
-import optparse
import io
def main():
- p = optparse.OptionParser(__doc__)
- options, args = p.parse_args()
-
- if len(args) < 1:
- p.error('no mode given')
+ import argparse
- mode = args.pop(0)
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument('mode', help='file mode', choices=('html', 'tex'))
+ parser.add_argument('file', nargs='+', help='input file(s)')
+ args = parser.parse_args()
- if mode not in ('html', 'tex'):
- p.error('unknown mode %s' % mode)
+ mode = args.mode
- for fn in args:
+ for fn in args.file:
with io.open(fn, 'r', encoding="utf-8") as f:
if mode == 'html':
lines = process_html(fn, f.readlines())