-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithubRestApi.py
More file actions
49 lines (36 loc) · 855 Bytes
/
githubRestApi.py
File metadata and controls
49 lines (36 loc) · 855 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
40
41
42
43
44
45
46
47
48
49
import requests as req
import json
def typing(txt):
l = 75000
i = len(txt) * l
j = 0
while j < i:
if(j % l) == 0:
print(txt[j // l], end="", flush=True)
j += 1
print()
def usr(usn):
r = req.get(f'https://api.github.com/users/{usn}/repos').text
j = json.loads(r)
return j
def repo(usn, name):
r = req.get(f'https://api.github.com/repos/{usn}/{name}').text
j = json.loads(r)
return j
usn = input("Enter username: ")
typing("Please wait...")
gh = usr(usn)
for i in gh:
lang = ""
if i["language"] != None:
lang = i["language"]
print(i["name"] + " (" + lang + ")")
print()
rn = input("Enter repo name: ").replace(" ", "-")
typing("Generating...")
rep = repo(usn, rn)
print(rep["name"])
print(rep["description"])
if rep["language"] != None:
print(rep["language"])
# print(gh)