-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgit.py
149 lines (119 loc) · 4.65 KB
/
git.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
from github import Github
from cloudmesh.configuration.Config import Config
from pprint import pprint
import requests
from textwrap import dedent
from pathlib import Path
import time
repos = [
# ["su21-reu-360","Carlos Theran", "CarlosTheran"],
["su21-reu-361","Jacques Fleischer","jpfleischer"],
["su21-reu-362","Kehinde Ezekiel","kehinde-ezekiel"],
["su21-reu-363","Whitney McNair","ohthatswhit"],
["su21-reu-364","David Umanzor","Zarthanix"],
["su21-reu-365","Victor Adankai","VictorWealth"]
# ["fa19-523-180", "Jonathon Grant","jongrant010"],
# ["fa19-523-181", "Max Falkenstein","maxf7399"],
# ["fa19-523-182", "Zak Siddiqui","zaksidd1"],
# ["fa19-523-183", "Brent Creech","bcreech40"],
# ["fa19-523-184", "Michael Floreak","mfloreak"],
# ["fa19-523-185", "Die Hu","syhu"],
# ["fa19-523-186", "Soowon Park","parksoow"],
# ["fa19-523-187", "Chris Fang","zihfang"],
# ["fa19-523-188", "Shivani Katukota","katukota"],
# ["fa19-523-189", "Huizhou Wang","aiai949"],
# ["fa19-523-190", "Skyler Konger","skonger"],
# ["fa19-523-191", "Yiyu Tao","oliviatao22"],
# ["fa19-523-192", "Jihoon Kim","Kim926"],
# ["fa19-523-193", "Lin-Fei Sung","lfsung1997"],
# ["fa19-523-194", "Ashley Minton","ashmmint"],
# ["fa19-523-195", "Kang Jie Gan","kanggan"],
# ["fa19-523-196", "Xinzhuo Zhang","zhanxinz"],
# ["fa19-523-198", "Dominic Matthys","dojomatt"],
# ["fa19-523-199", "Lakshya Gupta","lakshyagupta96"],
# ["fa19-523-200", "Naimesh Chaudhari","nchaudh03"],
# ["fa19-523-201", "Ross Bohlander","rbohland"],
# ["fa19-523-202", "Limeng Liu","liulim-Liu"],
# ["fa19-523-203", "Jisang Yoo","jisayoo"],
# ["fa19-523-204", "Andrew Dingman","acdingman"],
# ["fa19-523-205", "Senthil Palani","psendil"],
# ["fa19-523-206", "Lenin Arivukadal","wowlenin"],
# ["fa19-523-207", "Nihir Chadderwala","nihirc"],
#["fa19-523-208","Saravanan Natarajan", "sanata"],
#["fa19-523-209","Asya Kirgiz", "AsyaJ"],
#["fa19-523-210","Matthew Han", "matthewjhan"],
#["fa19-523-211","Yu-Hsi Chiang", "chiayuhs0718"],
#["fa19-523-212", "Josiah Clemons", "JLemon1"],
#["fa19-516-159", "Austin Zebrowski", "azebrowski"],
#"fa19-516-160","Shreyans Jain", "toshreyansjain"],
#["fa19-516-161","Jim Nelson", "JENelson77"],
#["fa19-516-162","Shivani Katukota, ", "katukota"],
#["fa19-516-163","John Hoerr", "jhoerr"],
#["fa19-516-164","Siddhesh Mirjankar", "smirjank"],
#["fa19-516-165","Zhi Wang", "zwang89"],
#["fa19-516-166","Brian Funk", "brianfunk3"],
#["fa19-516-167","William Screen", "william-screen"],
#["fa19-516-168","Deepak Deopura", "deepakdeopura"],
#["fa19-516-169","Harshawardhan Pandit", "hppanditims"]
#["fa19-516-170","Yanting Wan", "YantingWan"],
#["fa19-516-156", "Manikandan Nagarajan", "ManiNagarajan20"],
#["fa19-516-157", "Chenxu Wang", "wang542"],
#["fa19-516-158", "Daivik Dayanand", "Daivik1997"]
# ["fa19-516-000", "Gregor von Laszewski", "laszewsk"]
]
config = Config()
g = Github(config["cloudmesh.github.user"],
config["cloudmesh.github.password"])
org = g.get_organization("cloudmesh-community")
# repo = g.get_repo("cloudmesh-community/book")
# print (repo)
# print(g.get_user())
# print (org)
# pprint (dir(org))
# for t in org.get_teams():
# pprint (t)
ta_team = org.get_team(2631498)
# pprint (team)
# sys.exit()
# for r in org.get_repos():
# print (r)
# request = requests.get(f'https://api.github.com/users/{username}/reposper_page=1000')
# json = request.json()
# pprint (json)
# for i in range(0,len(json)):
# print("Project Number:",i+1)
## print("Project Name:",json[i]['name'])
# print("Project URL:",json[i]['svn_url'],"\n")
for r in repos:
name = r[0]
description = r[1]
firstname, lastname = description.split(" ", 1)
username = r[2]
print("creating", name, description)
repo = org.create_repo(name,
description=description,
license_template="apache-2.0")
readme = dedent(f"""
---
owner:
firstname: "{firstname}"
lastname: "{lastname}"
hid: "{name}"
community: "reu"
semester: "su21"
""").strip()
print(readme)
print("Add README.yaml")
repo.create_file("README.yml", "create the Readme.yaml", readme,
branch="main")
print("Add .gitignore")
with open(Path("../.gitignore").resolve()) as file:
gitignore = file.read()
repo.create_file(".gitignore", "create the .gitignore", gitignore,
branch="main")
try:
repo.add_to_collaborators(username, permission="write")
except Exception as e:
pass
ta_team.add_to_repos(repo)
ta_team.set_repo_permission(repo, "write")