forked from prathimacode-hub/Awesome_Python_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgithub_bot.py
32 lines (25 loc) · 879 Bytes
/
github_bot.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
from github import Github
#user login
g=Github("username","password")
#showing all the repositories of python
repos= g.search_repositories(query="language:python")
for i in repos:
print(i)
#for getting all the repos of user
for repo in g.get_user().get_repos():
print(repo.name)
#shows the no. of star of the repo
repo=g.get_repo("repository name")
repo.stargazers_count
#getting all the contents of particular repo
content=repo.get_contents("")
for content_fil in content:
print(content_fil)
#making a repo test and creating test file
user= g.get_user()
repo=user.create_repo('test')
repo.create_file("test.txt","commit","hello coders")
#deleting file from the repo
repo=g.get_repo("")#enter repository name inside the bracket
cont=repo.get_contents("test.txt")
repo.delete_file(cont.path,"remove test",cont.sha,branch='master')