forked from pandas-dev/pandas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_release_notes.py
95 lines (71 loc) · 2.37 KB
/
gen_release_notes.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
from __future__ import print_function
import sys
import json
from pandas.io.common import urlopen
from datetime import datetime
class Milestone(object):
def __init__(self, title, number):
self.title = title
self.number = number
def __eq__(self, other):
if isinstance(other, Milestone):
return self.number == other.number
return False
class Issue(object):
def __init__(self, title, labels, number, milestone, body, state):
self.title = title
self.labels = set([x['name'] for x in labels])
self.number = number
self.milestone = milestone
self.body = body
self.closed = state == 'closed'
def __eq__(self, other):
if isinstance(other, Issue):
return self.number == other.number
return False
def get_issues():
all_issues = []
page_number = 1
while True:
iss = _get_page(page_number)
if len(iss) == 0:
break
page_number += 1
all_issues.extend(iss)
return all_issues
def _get_page(page_number):
gh_url = ('https://api.github.com/repos/pydata/pandas/issues?'
'milestone=*&state=closed&assignee=*&page=%d') % page_number
with urlopen(gh_url) as resp:
rs = resp.readlines()[0]
jsondata = json.loads(rs)
issues = [Issue(x['title'], x['labels'], x['number'],
get_milestone(x['milestone']), x['body'], x['state'])
for x in jsondata]
return issues
def get_milestone(data):
if data is None:
return None
return Milestone(data['title'], data['number'])
def collate_label(issues, label):
lines = []
for x in issues:
if label in x.labels:
lines.append('\t- %s(#%d)' % (x.title, x.number))
return '\n'.join(lines)
def release_notes(milestone):
issues = get_issues()
headers = ['New Features', 'Improvements to existing features',
'API Changes', 'Bug fixes']
labels = ['New', 'Enhancement', 'API-Change', 'Bug']
rs = 'pandas %s' % milestone
rs += '\n' + ('=' * len(rs))
rs += '\n\n **Release date:** %s' % datetime.today().strftime('%B %d, %Y')
for i, h in enumerate(headers):
rs += '\n\n**%s**\n\n' % h
l = labels[i]
rs += collate_label(issues, l)
return rs
if __name__ == '__main__':
rs = release_notes(sys.argv[1])
print(rs)