-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
56 lines (47 loc) · 1.47 KB
/
run.py
File metadata and controls
56 lines (47 loc) · 1.47 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
"""
Entry point. Two modes:
* No args -> launch the Flask app on http://127.0.0.1:5000
* ``--cli <path/to/statement.xls>`` -> print analysis to stdout (handy for
scripts and CI smoke tests)
"""
from __future__ import annotations
import argparse
import json
import sys
from app import analyse
from app.web import create_app
def main() -> int:
parser = argparse.ArgumentParser(description="SNB Statement Analyzer")
parser.add_argument(
"--cli",
metavar="PATH",
help="Run on a single statement file and print JSON to stdout.",
)
parser.add_argument(
"--threshold",
type=float,
default=None,
help="Visa balance threshold to evaluate (in statement currency).",
)
parser.add_argument(
"--threshold-currency",
default="SAR",
help="Currency label for the threshold (display only).",
)
parser.add_argument("--host", default="127.0.0.1")
parser.add_argument("--port", type=int, default=5000)
parser.add_argument("--debug", action="store_true")
args = parser.parse_args()
if args.cli:
result = analyse(
args.cli,
visa_threshold=args.threshold,
visa_threshold_currency=args.threshold_currency,
)
print(json.dumps(result.to_payload(), indent=2, default=str))
return 0
app = create_app()
app.run(host=args.host, port=args.port, debug=args.debug)
return 0
if __name__ == "__main__":
sys.exit(main())