mirror of
https://github.com/hastagAB/Awesome-Python-Scripts.git
synced 2024-11-23 20:11:07 +00:00
Github CLI tool added. (#198)
* GithubBot added * add new project * Update README.md * Update README.md
This commit is contained in:
parent
e3db5f71f2
commit
aeb8537b70
9
Github_Bot/README.md
Normal file
9
Github_Bot/README.md
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
# Github_Bot
|
||||||
|
A CLI tool to get github user and repository details.
|
||||||
|
|
||||||
|
```
|
||||||
|
>python main.py -f user -l username
|
||||||
|
>python main.py -f repo -l username reponame
|
||||||
|
```
|
||||||
|
|
||||||
|
![](readme_assets/img.png)
|
49
Github_Bot/main.py
Normal file
49
Github_Bot/main.py
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
ap = argparse.ArgumentParser()
|
||||||
|
ap.add_argument("-f", "--function", required=True, help="user details or repo details")
|
||||||
|
ap.add_argument("-l", "--list", required=True, metavar="", nargs='+', default=[], help="handle and repo")
|
||||||
|
args = vars(ap.parse_args())
|
||||||
|
|
||||||
|
class GithubBot():
|
||||||
|
def __init__(self):
|
||||||
|
print('******************* GITHUB CLI TOOL *********************')
|
||||||
|
self.base_url = "https://api.github.com/"
|
||||||
|
|
||||||
|
def get_user_details(self, args):
|
||||||
|
url = self.base_url + "users/" + args[0]
|
||||||
|
res = requests.get(url)
|
||||||
|
print('*********** USER:', args[0], '***************')
|
||||||
|
if res.status_code == 200:
|
||||||
|
data = json.loads(res.text)
|
||||||
|
print("NAME: ", data["name"])
|
||||||
|
print("BIO: ", data["bio"])
|
||||||
|
print("LOCATION: ", data["location"])
|
||||||
|
print("FOLLOWERS COUNT: ", data["followers"])
|
||||||
|
print("FOLLOWING COUNT: ", data["following"])
|
||||||
|
else:
|
||||||
|
print("Error getting details")
|
||||||
|
|
||||||
|
def get_repo_details(self, args):
|
||||||
|
url = self.base_url + "repos/" + args[0] + "/" + args[1]
|
||||||
|
res = requests.get(url)
|
||||||
|
print('********* USER:', args[0], '| REPO:', args[1], '*********')
|
||||||
|
if res.status_code == 200:
|
||||||
|
data = json.loads(res.text)
|
||||||
|
print("URL: ", data["svn_url"])
|
||||||
|
print("STARS: ", data["stargazers_count"])
|
||||||
|
print("FORKS: ", data["forks"])
|
||||||
|
print("LANGUAGE: ", data["language"])
|
||||||
|
else:
|
||||||
|
print("Error getting details")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
obj = GithubBot()
|
||||||
|
function_map = {
|
||||||
|
'user': obj.get_user_details,
|
||||||
|
'repo': obj.get_repo_details,
|
||||||
|
}
|
||||||
|
function_map[args['function']](args['list'])
|
||||||
|
|
BIN
Github_Bot/readme_assets/img.png
Normal file
BIN
Github_Bot/readme_assets/img.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
5
Github_Bot/requirements.txt
Normal file
5
Github_Bot/requirements.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
certifi==2020.6.20
|
||||||
|
chardet==3.0.4
|
||||||
|
idna==2.10
|
||||||
|
requests==2.24.0
|
||||||
|
urllib3==1.25.11
|
|
@ -167,7 +167,7 @@ So far, the following projects have been integrated to this repo:
|
||||||
|[2048](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/2048)|[Krunal](https://github.com/gitkp11)
|
|[2048](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/2048)|[Krunal](https://github.com/gitkp11)
|
||||||
|[Spotify Downloader](spotify_downloader)|[Sagar Patel](https://github.com/sagar627)|
|
|[Spotify Downloader](spotify_downloader)|[Sagar Patel](https://github.com/sagar627)|
|
||||||
|[Download Page as PDF](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Download-page-as-pdf)|[Jeremias Gomes](https://github.com/j3r3mias)
|
|[Download Page as PDF](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/Download-page-as-pdf)|[Jeremias Gomes](https://github.com/j3r3mias)
|
||||||
|
|[GithubBot](https://github.com/hastagAB/Awesome-Python-Scripts/tree/master/GithubBot)|[Abhilasha](https://github.com/Abhilasha06)|
|
||||||
|
|
||||||
## How to use :
|
## How to use :
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user