-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetGithubNetwork.py
More file actions
31 lines (24 loc) · 946 Bytes
/
getGithubNetwork.py
File metadata and controls
31 lines (24 loc) · 946 Bytes
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
import os
import dotenv
import json
import argparse
from make.network.getDependencies import *
def setup():
parser = argparse.ArgumentParser(description = 'Get Github network from a given repository, using Github GraphQL API')
parser.add_argument('-r', '--repository', help = 'Repository name, like "pytorch/pytorch"', required=True)
parser.add_argument('-o', '--out', help = 'Destination json filename', required=True)
parser.add_argument('-d', '--depth', type=int, default=1, help='Depth of search')
args = parser.parse_args()
return args
def main():
args = setup()
dotenv.load_dotenv()
token = os.environ.get('GITHUB_TOKEN')
git = GithubGraph(token = token)
owner, name = args.repository.split('/')
jsonGraph = git.modelGithubRepoGraph(owner, name, depth = args.depth)
jsonGraph = open("dataset/json/{}".format(args.out), "w")
json.dump(git.json, jsonGraph, indent=4)
jsonGraph.close()
if __name__ == '__main__':
main()