-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.py
More file actions
29 lines (22 loc) · 929 Bytes
/
app.py
File metadata and controls
29 lines (22 loc) · 929 Bytes
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
import argparse
import json
import sys
from pathlib import Path
from rules_validation_api.validators.rules_validator import RulesValidation
GREEN = "\033[92m" # pragma: no cover
RESET = "\033[0m" # pragma: no cover
YELLOW = "\033[93m" # pragma: no cover
RED = "\033[91m" # pragma: no cover
def main() -> None: # pragma: no cover
parser = argparse.ArgumentParser(description="Validate campaign configuration.")
parser.add_argument("--config_path", required=True, help="Path to the campaign config JSON file")
args = parser.parse_args()
try:
with Path(args.config_path).open() as file:
json_data = json.load(file)
RulesValidation(**json_data)
sys.stdout.write(f"{GREEN}Valid Config{RESET}\n")
except ValueError as e:
sys.stderr.write(f"{YELLOW}Validation Error:{RESET} {RED}{e}{RESET}\n")
if __name__ == "__main__": # pragma: no cover
main()