├── .gitignore ├── GithubStat └── __init__.py ├── LICENSE ├── README.md └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | *.py[cod] 3 | *$py.class 4 | build/ 5 | develop-eggs/ 6 | dist/ 7 | eggs/ 8 | .eggs/ 9 | sdist/ 10 | wheels/ 11 | pip-wheel-metadata/ 12 | share/python-wheels/ 13 | *.egg-info/ 14 | .installed.cfg 15 | *.egg 16 | MANIFEST 17 | *.manifest 18 | *.spec 19 | pip-log.txt 20 | pip-delete-this-directory.txt 21 | .pytest_cache/ 22 | .env 23 | .venv 24 | env/ 25 | venv/ 26 | ENV/ 27 | env.bak/ 28 | venv.bak/ 29 | -------------------------------------------------------------------------------- /GithubStat/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: utf-8 -*- 3 | 4 | # MIT License 5 | # 6 | # Copyright (c) 2022 Tahmid Rayat 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | # 15 | # The above copyright notice and this permission notice shall be included in all 16 | # copies or substantial portions of the Software. 17 | # 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | # SOFTWARE. 25 | # 26 | # Copyright (C) 2022 HTR-TECH (https://github.com/htr-tech) 27 | # 28 | 29 | import os 30 | import sys 31 | import json 32 | import csv 33 | import six 34 | import requests 35 | 36 | info = """ 37 | [-] Username : %s 38 | 39 | [-] Name : %s 40 | [-] Followers : %s 41 | [-] Following : %s 42 | 43 | [-] Location : %s 44 | [-] Email : %s 45 | [-] Twitter : %s 46 | [-] Blog : %s 47 | [-] Company : %s 48 | [-] Hireable : %s 49 | 50 | [-] Total Repository : %s 51 | [-] Total Gists : %s 52 | [-] Joined Github at : %s 53 | [-] Recent Activity : %s 54 | 55 | [-] Github URL : https://github.com/%s 56 | [-] Repositories : https://github.com/%s/repositories 57 | [-] Avatar : %s 58 | """ 59 | 60 | def status(user): 61 | main = requests.get("https://api.github.com/users/%s" % (user)) 62 | if main.status_code == 200: 63 | pass 64 | elif main.status_code == 404: 65 | print('No Github Account with that Username !') 66 | sys.exit() 67 | else: 68 | print('Github api issue. Try again After Some Time') 69 | sys.exit() 70 | 71 | def stats(user): 72 | status(user) 73 | main = requests.get("https://api.github.com/users/%s" % (user)) 74 | dump = json.loads(main.text) 75 | 76 | h1 = dump['login'] 77 | h2 = dump['name'] 78 | h3 = dump['followers'] 79 | h4 = dump['following'] 80 | h5 = dump['location'] 81 | h6 = dump['email'] 82 | h7 = dump['twitter_username'] 83 | h8 = dump['blog'] 84 | h9 = dump['company'] 85 | h10 = dump['hireable'] 86 | h11 = dump['public_repos'] 87 | h12 = dump['public_gists'] 88 | h13 = dump['created_at'] 89 | h14 = dump['updated_at'] 90 | h15 = dump['avatar_url'] 91 | 92 | print(info % (h1, h2, h3, h4, h5, h6, h7, h8, 93 | h9, h10, h11, h12, h13, h14, h1, h1, h15)) 94 | 95 | orgs = requests.get("https://api.github.com/users/%s/orgs" % (user)) 96 | orgs_dump = json.loads(orgs.text) 97 | for hulu in orgs_dump: 98 | print('[-] Organization : {} '.format(hulu['login'])) 99 | 100 | stats=[] 101 | total_star, total_fork = 0, 0 102 | 103 | if h11 > 100: page_c = (h11 // 100) + 1 104 | else: page_c = 1 105 | 106 | for i in range(page_c): 107 | repos = requests.get("https://api.github.com/users/%s/repos?page=%s&per_page=100" % (user,i+1)) 108 | repo_dump = json.loads(repos.text) 109 | for x in repo_dump: 110 | stats.append((x['name'],x['stargazers_count'],x['forks_count'],x['clone_url'])) 111 | total_star += int(x['stargazers_count']) 112 | total_fork += int(x['forks_count']) 113 | 114 | print('') 115 | print('[-] Total Stars : '+str(total_star)) 116 | print('[-] Total Forks : '+str(total_fork)) 117 | print('') 118 | 119 | save_repo = six.moves.input('[-] Save Repository List as .csv ? [Y/n] : ') 120 | print('') 121 | 122 | if save_repo == "y" or save_repo == "Y": 123 | with open("%s.csv" % (user), "w") as f: 124 | output=csv.writer(f, lineterminator='\n') 125 | output.writerow(['Repository Name','Total Stars','Total Forks','Clone URL']) 126 | for row in stats: 127 | output.writerow(row) 128 | 129 | print("[-] File Saved as : %s.csv" % (user)) 130 | print('') 131 | else: 132 | pass 133 | 134 | note = """ 135 | GithubStat (c) Tahmid Rayat 136 | 137 | A Simple Github User Statistics Meter based on Github-API. 138 | 139 | Type GithubStat 140 | 141 | Example : GithubStat HTR-TECH 142 | 143 | If you Like this Project then don't Forget to leave a Star :) 144 | """ 145 | 146 | def main(): 147 | if len(sys.argv) >= 2: 148 | try: 149 | stats(sys.argv[1]) 150 | except Exception as exceptions: 151 | sys.exit(exceptions) 152 | else: 153 | sys.exit(note) 154 | 155 | if __name__ == '__main__': 156 | main() 157 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Tahmid Rayat 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GithubStat 2 | **A Simple Github User Statistics Meter based on Github-API.** 3 | 4 | [![Author](https://img.shields.io/badge/Author-HTR--TECH-blue)](https://github.com/htr-tech) 5 | [![Opensource](https://img.shields.io/badge/Open%20Source-Yes-green)](#) 6 | [![Version](https://badge.fury.io/py/GithubStat.svg)](https://badge.fury.io/py/GithubStat) 7 | [![Python Version](https://img.shields.io/pypi/pyversions/GithubStat.svg)](https://pypi.org/project/GithubStat) 8 | [![Total Downloads](https://pepy.tech/badge/GithubStat)](https://pepy.tech/project/GithubStat) 9 | [![Monthly Downloads](https://pepy.tech/badge/GithubStat/month)](https://pepy.tech/project/GithubStat/month) 10 | 11 | ### Installation : 12 | 13 | - **Install GithubStat via Pypi :** 14 | ``` 15 | $ pip install GithubStat 16 | ``` 17 | - Now simply Type 18 | ``` 19 | $ GithubStat 20 | ``` 21 | - **Use it via console :** 22 | ```python 23 | >>> from GithubStat.__init__ import stats 24 | >>> stats('htr-tech') 25 | 26 | [-] Username : htr-tech 27 | 28 | [-] Name : Tahmid Rayat 29 | [-] Followers : 1969 30 | [-] Following : 12 31 | ...... 32 | ``` 33 | - **Install GithubStat via Github :** 34 | ``` 35 | $ git clone https://github.com/htr-tech/GithubStat.git 36 | $ cd GithubStat 37 | $ python setup.py install 38 | $ GithubStat 39 | ``` 40 | 41 | ***Copyright (c) 2022 Tahmid Rayat Under [MIT LICENSE](https://github.com/htr-tech/GithubStat/blob/master/LICENSE#L1)*** 42 | 43 | ### *📡 Get in Touch :* 44 | [![Github](https://img.shields.io/badge/Github-525252?style=for-the-badge&logo=github)](https://github.com/htr-tech) 45 | [![Facebook](https://img.shields.io/badge/Facebook-3b5998?style=for-the-badge&logo=facebook)](https://fb.com/tahmid.rayat.official) 46 | [![Instagram](https://img.shields.io/badge/Instagram-8a3ab9?style=for-the-badge&logo=instagram)](https://www.instagram.com/tahmid.rayat) 47 | 48 | 49 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | from setuptools import find_packages 3 | 4 | with open("README.md", "r") as markdown: 5 | long_description = markdown.read() 6 | 7 | setup( 8 | name = "GithubStat", 9 | version = "1.2", 10 | license = "MIT", 11 | author = "HTR-TECH", 12 | author_email = "tahmidrayat@gmail.com", 13 | url = "https://github.com/htr-tech/GithubStat", 14 | description = "A Simple Github User Statistics Meter based on Github-API.", 15 | long_description = long_description, 16 | long_description_content_type = "text/markdown", 17 | classifiers = [ 18 | "License :: OSI Approved :: MIT License", 19 | "Operating System :: OS Independent", 20 | "Programming Language :: Python", 21 | 'Programming Language :: Python :: 2', 22 | 'Programming Language :: Python :: 2.7', 23 | 'Programming Language :: Python :: 3', 24 | 'Programming Language :: Python :: 3.5', 25 | 'Programming Language :: Python :: 3.6', 26 | 'Programming Language :: Python :: 3.7', 27 | 'Programming Language :: Python :: 3.8', 28 | 'Programming Language :: Python :: 3.9', 29 | 'Programming Language :: Python :: 3.10', 30 | 'Programming Language :: Python :: 3.11', 31 | ], 32 | packages = find_packages(), 33 | zip_safe = True, 34 | install_requires = ["requests >= 2.25.0", "six >= 1.13.0"], 35 | entry_points = { 36 | 'console_scripts': [ 37 | 'GithubStat=GithubStat.__init__:main', 38 | 'githubstat=GithubStat.__init__:main', 39 | 'Gitstat=GithubStat.__init__:main', 40 | 'gitstat=GithubStat.__init__:main', 41 | ] 42 | } 43 | ) 44 | 45 | --------------------------------------------------------------------------------