|
28 | 28 | MEMBER_INFO = 'https://whimsy.apache.org/public/member-info.json' |
29 | 29 | MEMBERS_MD ='content/foundation/members.md' |
30 | 30 |
|
31 | | -def main(): |
| 31 | +def main(failOnWarn=False): |
32 | 32 | member_info = requests.get(MEMBER_INFO).json() |
33 | 33 | members = member_info['members'] |
34 | 34 | ex_members = member_info['ex_members'] |
35 | 35 | errors = 0 |
| 36 | + warnings = 0 |
36 | 37 | with open(MEMBERS_MD, 'r', encoding='utf-8') as md: |
37 | 38 | section = None |
38 | 39 | for line in md: |
@@ -61,25 +62,38 @@ def main(): |
61 | 62 | name = parts.pop(0).strip() |
62 | 63 | if section == 'members': |
63 | 64 | if not availid in members: |
| 65 | + level = '' |
64 | 66 | if availid in ex_members: |
65 | 67 | status = f"is listed in Whimsy with status '{ex_members.get(availid)}'" |
| 68 | + warnings += 1 |
| 69 | + level = 'WARNING' |
66 | 70 | else: |
67 | 71 | status = "was not found in Whimsy" |
68 | | - errors += 1 |
69 | | - print(f"'{availid}' ({name}) is listed in the 'members' section of `content/foundation/members.md`, but {status}") |
| 72 | + errors += 1 |
| 73 | + level = 'ERROR' |
| 74 | + print(f"{level}: '{availid}' ({name}) is listed in the 'members' section of `content/foundation/members.md`, but {status}") |
70 | 75 | elif section == 'emeritus': |
71 | 76 | if availid != '?' and not availid in ex_members: |
72 | 77 | if availid in members: |
73 | 78 | status = "is listed in Whimsy as an ASF Member" |
| 79 | + warnings += 1 |
| 80 | + level = 'WARNING' |
74 | 81 | else: |
75 | 82 | status = "was not found in Whimsy" |
76 | | - print(f"'{availid}' ({name}) is listed in the 'emeritus' section of `content/foundation/members.md`, but {status}") |
77 | | - errors += 1 |
| 83 | + errors += 1 |
| 84 | + level = 'ERROR' |
| 85 | + print(f"{level}: '{availid}' ({name}) is listed in the 'emeritus' section of `content/foundation/members.md`, but {status}") |
| 86 | + print(f"Detected {errors} error(s) and {warnings} warnings. ") |
78 | 87 | if errors > 0: |
79 | | - print(f"Detected {errors} error(s). ") |
| 88 | + print("Errors detected, failing") |
80 | 89 | sys.exit(1) |
| 90 | + elif warnings > 0: |
| 91 | + if failOnWarn: |
| 92 | + print("Warnings detected, failing") |
| 93 | + else: |
| 94 | + print("Warnings detected") |
81 | 95 | else: |
82 | | - print("No errors detected") |
| 96 | + print("No errors or warnings detected") |
83 | 97 |
|
84 | 98 | if __name__ == '__main__': |
85 | | - main() |
| 99 | + main(len(sys.argv) >1 and sys.argv[1] == 'failOnWarn') |
0 commit comments