-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
39 lines (30 loc) · 1.15 KB
/
utils.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
"""Utilities for yapapi example scripts."""
import argparse
from datetime import datetime, timezone
from pathlib import Path
import tempfile
import colorama # type: ignore
TEXT_COLOR_RED = "\033[31;1m"
TEXT_COLOR_GREEN = "\033[32;1m"
TEXT_COLOR_YELLOW = "\033[33;1m"
TEXT_COLOR_BLUE = "\033[34;1m"
TEXT_COLOR_MAGENTA = "\033[35;1m"
TEXT_COLOR_CYAN = "\033[36;1m"
TEXT_COLOR_WHITE = "\033[37;1m"
TEXT_COLOR_DEFAULT = "\033[0m"
colorama.init()
def build_parser(description: str):
current_time_str = datetime.now(tz=timezone.utc).strftime("%Y%m%d_%H%M%S%z")
default_log_path = Path(tempfile.gettempdir()) / f"yapapi_{current_time_str}.log"
parser = argparse.ArgumentParser(description=description)
parser.add_argument("--driver", help="Payment driver name, for example `zksync`")
parser.add_argument("--network", help="Network name, for example `rinkeby`")
parser.add_argument(
"--subnet-tag", default="devnet-beta.2", help="Subnet name; default: %(default)s"
)
parser.add_argument(
"--log-file",
default=str(default_log_path),
help="Log file for YAPAPI; default: %(default)s",
)
return parser