-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgithub.py
52 lines (43 loc) · 1.69 KB
/
github.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
import requests
class Github:
def __init__(self):
self.api_url = "https://api.github.com"
self.access_token = "kendi hesabınızın tokenını girmeniz gerekiyor."
def getUser(self, username):
response = requests.get(self.api_url+"/users/"+username)
return response.json()
def getRepositories(self, username):
response = requests.get(self.api_url+"/users/"+username+"/repos")
return response.json()
def createRepository(self, name):
response = requests.post(self.api_url+"/user/repos?access_token="+self.access_token, json={
"name": name,
"description": "This is your first repository",
"homepage": "https://github.com",
"private": False,
"has_issues": True,
"has_projects": True,
"has_wiki": True
})
return response.json()
github = Github()
while True:
secim = input("1- Find User\n2- Get Repository\n3- Create Reporsitory\n4- Exit\nSeçim: ")
if secim == "4":
break
else:
if secim == "1":
username = input("username: ")
result = github.getUser(username)
print(f'name : {result["name"]}\nbio: {result["bio"]}\nlocation: {result["location"]}\npublic repository: {result["public_repos"]}\nfollowers: {result["followers"]}')
elif secim == "2":
username = input("username: ")
result = github.getRepositories(username)
for repo in result:
print(repo["name"])
elif secim == "3":
name = input("repository name: ")
result = github.createRepository(name)
print(result)
else:
print("yanlış seçim")