-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreq_github.py
More file actions
39 lines (26 loc) · 959 Bytes
/
req_github.py
File metadata and controls
39 lines (26 loc) · 959 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
32
33
34
35
36
37
38
39
import requests, json
class RepositoryGitHub:
def __init__(self, user):
self.user = user
def request_api(self):
response = requests.get(f'https://api.github.com/users/{self.user}/repos')
if (response.status_code == 200):
return response.json()
else:
return response.status_code
def show_reposity(self):
data = self.request_api()
if(type(data) is not int):
for i in range(len(data)):
print(f'Reposity: {data[i]["name"]}\nOwner: {data[i]["owner"]["login"]}\n')
else:
print(data)
def show_keys(self):
lista_dict = self.request_api()
if(type(lista_dict) is not int):
print(lista_dict[0].keys())
else:
print('Not Found')
user = RepositoryGitHub('torvalds')
user.show_reposity()
#user.show_keys()