This repository has been archived by the owner on Oct 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepos.py
65 lines (56 loc) · 1.72 KB
/
repos.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
51
52
53
54
55
56
57
58
59
60
61
62
63
import django
import github
import os
import sys
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings")
django.setup()
from projects.models import Author, Platform, Project, Publication, Tag
gh_token = os.environ['GH_TOKEN']
gh = github.Github(gh_token)
gh_me = gh.get_user()
sys.stderr.write("Logged into GitHub as %s\n"%(gh_me.login))
# https://github.com/jdblischak/singlecell-qtl
repo = gh.get_repo("jdblischak/singlecell-qtl")
aut, created = Author.objects.get_or_create(
name=repo.owner.login,
email="[email protected]",
avatar=repo.owner.avatar_url
)
repo.get_topics()
pub, created = Publication.objects.get_or_create(
doi="10.1371/journal.pgen.1008045",
title="Discovery and characterization of variance QTLs in human induced pluripotent stem cells."
)
proj, created = Project.objects.get_or_create(
name=repo.name,
url=repo.html_url,
author=aut,
platform=Platform.objects.get(name="GitHub")
)
proj.publications.add(pub)
# https://github.com/jdblischak/fucci-seq
repo = gh.get_repo("jdblischak/fucci-seq")
tags = repo.get_topics()
proj, created = Project.objects.get_or_create(
name=repo.name,
url=repo.html_url,
author=aut,
platform=Platform.objects.get(name="GitHub")
)
for tag in tags:
tag_model, created = Tag.objects.get_or_create(name=tag)
proj.tags.add(tag)
# https://github.com/stephenslab/wflow-divvy
repo = gh.get_repo("stephenslab/wflow-divvy")
aut, created = Author.objects.get_or_create(
name=repo.owner.login,
email="[email protected]",
avatar=repo.owner.avatar_url
)
repo.get_topics()
proj, created = Project.objects.get_or_create(
name=repo.name,
url=repo.html_url,
author=aut,
platform=Platform.objects.get(name="GitHub")
)