forked from 99x/99x.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi_process.py
31 lines (23 loc) · 813 Bytes
/
api_process.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
#! /usr/bin/env python
# Takes the raw GitHub API response from
# https://api.github.com/orgs/LinkedIn/repos?page=1&per_page=100
# and produces a new file with only the keys (and associated values) that are
# used for building the website.
#
# usage: python api_process.py <file with raw API response>
import json
import sys
api_response_file = sys.argv[1]
with open(api_response_file, "r") as f:
gh_data = json.load(f)
required_keys = set(["language", "name", "size", "forks", "watchers_count", \
"description", "html_url"])
filtered_repos = list()
for repo in gh_data:
filtered_repo = dict()
for k, v in repo.iteritems():
if k in required_keys:
filtered_repo[k] = v
filtered_repos.append(filtered_repo)
with open("github-api-response.js", "w+") as f:
json.dump(filtered_repos, f)