Created
January 26, 2018 07:09
-
-
Save totetmatt/7e76ddfe16971deaa8b6a48567317bf1 to your computer and use it in GitHub Desktop.
Script to generate the contributor <-> project graph from an organization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from github import Github | |
import csv | |
GITHUB_TOKEN="" | |
ORGANIZATION='' | |
# or using an access token | |
g = Github(GITHUB_TOKEN) | |
with open('git_network.node.csv','w') as nodes: | |
writer_node = csv.DictWriter(nodes,fieldnames=['id','label','type']) | |
writer_node.writeheader() | |
with open('git_network.edge.csv','w') as edges: | |
writer_edge = csv.DictWriter(edges,fieldnames=['source','target']) | |
writer_edge.writeheader() | |
# Then play with your Github objects: | |
for repo in g.get_organization(ORGANIZATION).get_repos(): | |
print(repo.name) | |
writer_node.writerow({'id':repo.name,'label':repo.name,'type':'repo'}) | |
for c in repo.get_contributors(): | |
writer_node.writerow({'id':c.login,'label':c.name,'type':'user'}) | |
writer_edge.writerow({'source':c.login,'target':repo.name}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment