-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathupdate-nfr.py
50 lines (40 loc) · 1.43 KB
/
update-nfr.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
import requests
import json
print("Getting NFR Reactions")
comments = 'https://api.github.com/repos/phalcon/cphalcon/issues/14608/comments?page='
result = {}
for i in range(1, 10):
url = f"{comments}{i}"
headers = {
'Accept': 'application/vnd.github.squirrel-girl-preview+json',
'User-Agent': 'Phalcon Agent'
}
response = requests.get(url, headers=headers)
content = response.text
print(f"Got content {i}")
data = json.loads(content)
for comment in data:
id = comment.get('id', '')
url = comment.get('html_url', '')
body = comment.get('body', '')
reactions = comment.get('reactions', {})
plusone = reactions.get('+1', 0)
body = body.split('\n')[0].replace('\r', '').replace('\r\n', '')
plusone = f"{int(plusone):03}"
result[f"{plusone}-{id}"] = {
'reaction': plusone,
'body': f"[{body}]({url})"
}
print("Sorting Results")
sorted_result = dict(sorted(result.items(), key=lambda item: item[0], reverse=True))
print("Creating Content")
output = "# New Feature Request List\n"
output += "- - -\n\n"
output += "| Votes | Description |\n"
output += "|--------|-------------------------|\n"
for item in sorted_result.values():
output += f"| {item['reaction']} | {item['body']} |\n"
output += "\n"
file_name = 'docs/new-feature-request-list.md'
with open(file_name, 'w') as file:
file.write(output)