-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgenerate-candidates.py
More file actions
executable file
·66 lines (60 loc) · 2.25 KB
/
generate-candidates.py
File metadata and controls
executable file
·66 lines (60 loc) · 2.25 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
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
import csv
import sys
import os
import subprocess
import json
TIMESTAMP = 'Timestamp'
NAME = 'Full Name'
EMAIL = 'Preferred email address'
TEAM_PROMPT = 'Which Area Team would you like to volunteer for?'
GITHUB = 'GitHub handle'
STATEMENT = 'Candidate Statement (Markdown formatting allowed)'
def QueryCommitters():
ghCommand = ['gh', 'api', '-H', 'Accept: application/vnd.github+json',
'-H', 'X-GitHub-Api-Version: 2022-11-28', '--paginate',
'/orgs/llvm/teams/llvm-committers/members']
status = subprocess.check_output(ghCommand)
committers = json.loads(status)
return committers
def main():
committers = QueryCommitters()
print('%d committers identified' % len(committers))
if len(sys.argv) > 1:
with open(sys.argv[1], 'w') as file:
file.write('eligible_voters:\n')
for committer in committers:
file.write(' - %s\n' % committer['login'])
def main():
election_dir = sys.argv[1]
candidates = sys.argv[2]
committers = [committer['login'] for committer in QueryCommitters()]
nominees = {'LLVM':[], 'Clang':[], 'MLIR':[], 'Infrastructure':[]}
with open(candidates, 'r') as file:
data = csv.DictReader(file)
for row in data:
GitHub = row[GITHUB].removeprefix('https://github.com/')
Status = ''
if GitHub not in committers:
Status = ' - **Ineligible**'
for team in row[TEAM_PROMPT].split(','):
candidate_md = os.path.join(election_dir, team.strip(), 'candidate-%s.md' % GitHub)
nominees[team.strip()].append('* %s - %s%s' % (GitHub, row[NAME], Status))
#if os.path.exists(candidate_md):
# continue
with open(candidate_md, 'w') as candidate_file:
candidate_file.write('---\n')
candidate_file.write('name: %s\n' % row[NAME])
candidate_file.write('ID: %s\n' % GitHub)
candidate_file.write('info:\n')
candidate_file.write(' - github: %s\n' % GitHub)
candidate_file.write(' - name: %s\n' % row[NAME])
candidate_file.write('---\n')
candidate_file.write(row[STATEMENT])
candidate_file.write('\n')
for team in nominees:
print('## %s' % team)
for nominee in nominees[team]:
print(nominee)
if __name__ == '__main__':
main()