-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
63 lines (51 loc) · 1.45 KB
/
main.py
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
import os
import argparse
from swetest.swetest import Swetest
from prettytable import PrettyTable
from pathlib import Path
from typing import List, Dict
import string
def main():
"""
Parses command line arguments and executes the swetest application.
Args:
None
Returns:
None
"""
EPHE_DIR = os.path.join(Path(".").resolve(), "ephemeris/")
parser = argparse.ArgumentParser(
prog="swetest",
description=(
"A Python Wrapper for swetest an commandline tool"
"that calculates with high precision the positions"
"of heavenly body's."
),
)
parser.add_help = False
parser.add_argument(
"-q", "--query", help="Query string for swetest", required=True
)
parser.add_argument(
"-p", "--path", help="Path to swetest binary", default=None
)
parser.add_argument(
"-h",
"--help",
action="store_true",
help="Show this help message and exit",
)
args = parser.parse_args()
try:
swetest = Swetest(args.path if args.path else EPHE_DIR)
if args.query.lower() == "--help":
print(swetest.set_query("-h").execute().get_output())
else:
swetest.set_query(args.query)
swetest.execute()
response = swetest.response()
print(response["output"])
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
main()