-
Notifications
You must be signed in to change notification settings - Fork 12
/
pr-agenda.py
executable file
·128 lines (106 loc) · 4.05 KB
/
pr-agenda.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env python
# prints out agenda and timetable from agenda requests
# run this
# pr-agenda.py <session> [--write]
import argparse
alltimes = []
alltalks = {}
def addtalk(agendaitem):
if agendaitem:
if agendaitem.get('wgdoc'):
alltalks.setdefault('wgdocs', []).append(agendaitem)
else:
alltalks.setdefault('nonwgdocs', []).append(agendaitem)
def readf(filename):
with open(filename, encoding="ascii") as f:
lines = f.readlines()
lines = [l.rstrip() for l in lines]
if '## Requests' in lines:
item = lines.index('## Requests')
lines = lines[item+1::]
return lines
def getitems(newlines):
agendaitem = {}
for l in newlines:
if not l:
continue
fields = l.split()
if l.startswith('*'):
# new agenda item
addtalk(agendaitem)
title = ' '.join(fields[1:])
title = title.replace('Draft name: ', '')
agendaitem = {}
agendaitem.setdefault('title', title)
if 'Datatracker URL' in l:
url = fields[-1]
wgdoc = bool('draft-ietf-dnsop' in url)
agendaitem.setdefault('url', fields[-1])
agendaitem.setdefault('wgdoc', wgdoc)
if 'Requester Email' in l:
agendaitem.setdefault('email', ' '.join(fields[3::]))
if 'Time Requested' in l:
agendaitem.setdefault('time', fields[3].replace('min', ''))
if 'DocType' in l:
doctype = ' '.join(fields[2::]).lower()
if doctype not in ['current', 'for consideration', 'i-d']:
agendaitem.setdefault('doctype', ' '.join(fields[2::]))
if 'Remark' in l:
agendaitem.setdefault('remark', ' '.join(fields[2::]))
addtalk(agendaitem)
def printitem(docs):
lines = []
for i in docs:
lines.append(f"* {i.get('title')}")
lines.append(f" - {i.get('url')}")
lines.append(f" - {i.get('email')}, {i.get('time')}")
lines.append(" - Chairs Action:")
if i.get('remark'):
lines.append(f" - Remark: {i.get('remark')}")
if i.get('doctype'):
lines.append(f" - DocType: {i.get('doctype')}")
lines.append("")
alltimes.append(f"{i.get('title')}\t{i.get('email')}\t{i.get('time')}\n")
return lines
def writef(filename, records):
with open(filename, "w", encoding="ascii") as f:
for r in records or []:
f.write(f"{r}\n")
def printitems(args):
newlines = []
alltimes.append("Opening, Note Well and Chairs Updates\tChairs\t15\n")
alltimes.append("Hackathon Results\tChairs\t10\n")
alltimes.append('\n### Current Working Group Business\n')
newlines.append('\n### Current Working Group Business\n')
newlines.extend(printitem(alltalks.get('wgdocs')))
alltimes.append('\n### For Consideration\n')
newlines.append('\n### For Consideration\n')
newlines.extend(printitem(alltalks.get('nonwgdocs')))
print("------\n# Agenda\n")
if args.write:
ofile = f"dnsop-ietf{args.session}-docs.md"
writef(ofile, newlines)
print(f"import {ofile} into dnsop-ietf{args.session}/dnsop-ietf{args.session}-agenda.md")
else:
for t in newlines:
print(t)
print("------\n# Timetable\n")
if args.write:
ofile = f"dnsop-ietf{args.session}-times.tsv"
writef(ofile, alltimes)
print(f"import {ofile} into timetable")
else:
for t in alltimes:
print(t)
def main():
parser = argparse.ArgumentParser(description='Convert Agenda Requests into Agenda')
parser.add_argument('session', help='Meeting Number (1##)')
parser.add_argument('--write', action='store_true', help='Write Files')
# parser.add_argument('--verbose', action='store_true', help='Be more Verbose')
args = parser.parse_args()
requestfile = f"dnsop-ietf{args.session}/dnsop-ietf{args.session}-agenda-requests.md"
lines = readf(requestfile)
getitems(lines)
printitems(args)
if __name__ == "__main__":
main()