Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a python project #27

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Github Bot

## Aim

To do all the work on github like making repo,file and deleting or updating in an easy manner

## Purpose

Here we will perform different tasks of github

## Short description of package/script

Here using github library we had done some tasks as below:
- printing all repositories related to a specific langauge
- viewing all repositories of user account
- login on github
- view number of stars of a spefic repository
- create repository on github using python
- push files ina repositroy using python
- delete file in a repository

List out the libraries imported->github


## Workflow of the Project

First we need to install github library then we just need to run the script and perform the tasks.


## Setup instructions
For setup we need to have github username and password with us and we need to provide it in the script , then we can perform task as per our requirement.




## Output
- Getting all python repos
![image](Image/output_1(git).png)

- making sample repo
![image](Image/output_2(git).png)

- making sample file
![image](Image/output_3(git).png)
1 change: 1 addition & 0 deletions projects/Build-Github-Bot-With-Python/Image/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
It has images of the bot.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions projects/Build-Github-Bot-With-Python/github_bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,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')