-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.py
45 lines (44 loc) · 2.41 KB
/
generate.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
import requests
import json
if __name__ == '__main__':
with open('prologue.md', 'r') as handle:
prologue = handle.read()
quote = lambda s: '`%s`' % s
proxies = {
'http': 'socks5://localhost:1080',
'https': 'socks5://localhost:1080'
}
url = 'https://summerofcode.withgoogle.com/api/program/current/organization/?page=1&page_size=50'
output = open('README.md', 'w', encoding='utf-8')
output.write(prologue)
while url is not None:
obj = requests.get(url, proxies=proxies).json()
url = obj['next']
for item in obj['results']:
output.write('\n## [%s](%s)\n' % (item['name'], item['website_url']))
output.write('\n**%s**\n' % item['precis'])
output.write('\n[Ideas List](%s) | ' % item['ideas_list'])
output.write('[Description](description/%s.md)\n' % item['slug'])
output.write('\n* Category: ' + item['category'])
output.write('\n* Techonology: %s' % ', '.join(map(quote, item['technology_tags'])))
output.write('\n* Topics: %s' % ', '.join(map(quote, item['topic_tags'])))
output.write('\n* Tags: %s' % ', '.join(map(quote, item['proposal_tags'])))
if item['contact_method'] is not None:
output.write('\n* Contact: %s' % item['contact_method'])
if item['mailing_list'] is not None:
output.write('\n* Mailing List: %s' % item['mailing_list'])
if item['twitter_url'] is not None:
output.write('\n* Twitter: %s' % item['twitter_url'])
if item['blog_url'] is not None:
output.write('\n* Blog: %s' % item['blog_url'])
if item['primary_open_source_license'] is not None:
output.write('\n* Primary Open Source License: %s' % item['primary_open_source_license'])
output.write('\n')
with open('description/%s.md' % item['slug'], 'w', encoding='utf-8') as handle:
handle.write('\n# [%s](%s)\n' % (item['name'], item['website_url']))
handle.write('\n[Back to catalogue](../README.md#%s)\n' % item['slug'])
handle.write('\n%s\n' % item['description'])
if item['application_instructions'] is not None:
handle.write('\n# Application Instructions\n')
handle.write('\n* Twitter: %s' % item['application_instructions'])
print('Done.')