-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathshow_ahelp.py
More file actions
executable file
·65 lines (40 loc) · 1.26 KB
/
show_ahelp.py
File metadata and controls
executable file
·65 lines (40 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
"""
Usage:
./show_ahelp.py symbol
Aim:
Create ahelp output based on sherpa documentation. A single-symbol
version of doc2ahelp.py with no output file.
The aim is to make it easy to see if changes to the code affects
the output for a symbol.
"""
import os
import tempfile
from xml.etree.ElementTree import dump
from sherpa.astro import ui
from parsers.sherpa import unwanted
from helpers import process_symbol
def convert_and_view(symbol: str) -> None:
"""Convert a symbol to an ahelp file.
Parameters
----------
symbol : str
The name of the symbol to convert.
"""
sym = getattr(ui, symbol, None)
if sym is None:
raise ValueError(f"Unknown symbol <{symbol}>")
if unwanted(symbol, sym):
raise ValueError(f"Apparently <{symbol}> is unwanted")
doc = process_symbol(symbol, sym)
dump(doc)
help_str = """Dump the converted ahelp for a symbol."""
if __name__ == "__main__":
import argparse
import sys
parser = argparse.ArgumentParser(description=help_str,
prog=sys.argv[0])
parser.add_argument("symbol",
help="The symbol to convert")
args = parser.parse_args(sys.argv[1:])
convert_and_view(args.symbol)