-
Notifications
You must be signed in to change notification settings - Fork 5
/
validate.py
executable file
·66 lines (55 loc) · 2.07 KB
/
validate.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
64
65
66
#!/usr/bin/env python
import argparse
from dcctools.config import Configuration
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--config",
default="config.json",
help='Configuration file (default "config.json")',
)
args = parser.parse_args()
return args
def do_validate(c):
# N.B. at time of PR household files don't have metadata associated with them.
# Will be fixed in an upcoming patch to data-owner-tools
missing, unexpected, metadata_issues = c.validate_all_present()
if len(missing) == 0:
print("All necessary input is present")
else:
if len(missing) > 1:
warning_txt = "Multiple expected files are missing"
elif len(missing) == 1:
warning_txt = "One expected file is missing"
print(f"WARNING: {warning_txt}")
print("\nMissing files:")
for filename in sorted(missing):
print(f"\t{filename}")
if len(unexpected) > 0:
print("\nWARNING: Individual and household hashes appear to be present")
print("at the same time, or other unexpected files are in the inbox.")
print("\nUnexpected files:")
for filename in sorted(unexpected):
print(f"\t{filename}")
else:
print("\nNo unexpected files are present")
if len(metadata_issues) == 0:
print("\nNo issues are present in the metadata files for each system")
else:
if len(metadata_issues) == 1:
print(f"\nWARNING: {metadata_issues[0]}")
else:
print("\nWARNING: multiple issues found with metadata files")
for issue in metadata_issues:
print(f"\t{issue}")
config_issues = c.validate_config()
if config_issues:
print(f"\nWARNING: Found {len(config_issues)} issues in config file:")
for issue in config_issues:
print(f"\t{issue}")
else:
print("\nNo issues are present in config file")
if __name__ == "__main__":
args = parse_args()
config = Configuration(args.config)
do_validate(config)