Skip to content

Commit 8da2052

Browse files
committed
First Release
1 parent fd9320d commit 8da2052

3 files changed

Lines changed: 226 additions & 0 deletions

File tree

GithubStat/__init__.py

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
#!/usr/bin/python
2+
# -*- coding: utf-8 -*-
3+
4+
# MIT License
5+
#
6+
# Copyright (c) 2021 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) 2021 HTR-TECH (https://github.com/htr-tech)
27+
#
28+
29+
import os
30+
import sys
31+
import json
32+
import six
33+
import requests
34+
35+
info = """
36+
[-] Username : %s
37+
38+
[-] Name : %s
39+
[-] Followers : %s
40+
[-] Following : %s
41+
42+
[-] Location : %s
43+
[-] Email : %s
44+
[-] Twitter : %s
45+
[-] Blog : %s
46+
[-] Company : %s
47+
[-] Hireable : %s
48+
49+
[-] Total Repository : %s
50+
[-] Total Gists : %s
51+
[-] Joined Github at : %s
52+
[-] Recent Activity : %s
53+
54+
[-] Github URL : https://github.com/%s
55+
[-] Repositories : https://github.com/%s/repositories
56+
[-] Avatar : %s
57+
"""
58+
59+
def status(user):
60+
main = requests.get("https://api.github.com/users/%s" % (user))
61+
if main.status_code == 200:
62+
pass
63+
elif main.status_code == 404:
64+
print('No Github Account with that Username !')
65+
sys.exit()
66+
else:
67+
print('Try again After Some Time')
68+
sys.exit()
69+
70+
def stats(user):
71+
status(user)
72+
main = requests.get("https://api.github.com/users/%s" % (user))
73+
dump = json.loads(main.text)
74+
75+
h1 = dump['login']
76+
h2 = dump['name']
77+
h3 = dump['followers']
78+
h4 = dump['following']
79+
h5 = dump['location']
80+
h6 = dump['email']
81+
h7 = dump['twitter_username']
82+
h8 = dump['blog']
83+
h9 = dump['company']
84+
h10 = dump['hireable']
85+
h11 = dump['public_repos']
86+
h12 = dump['public_gists']
87+
h13 = dump['created_at']
88+
h14 = dump['updated_at']
89+
h15 = dump['avatar_url']
90+
91+
print(info % (h1, h2, h3, h4, h5, h6, h7, h8,
92+
h9, h10, h11, h12, h13, h14, h1, h1, h15))
93+
94+
orgs = requests.get("https://api.github.com/users/%s/orgs" % (user))
95+
orgs_dump = json.loads(orgs.text)
96+
for hulu in orgs_dump:
97+
print('[-] Organization : {} '.format(hulu['login']))
98+
99+
list_repo = six.moves.input(
100+
'\n[-] Wanna List repositories [Max 100] [Y/n] : ')
101+
print('')
102+
103+
if list_repo == "y" or list_repo == "Y":
104+
repos = requests.get(
105+
"https://api.github.com/users/%s/repos?per_page=100" % (user))
106+
repo_dump = json.loads(repos.text)
107+
for bagh in repo_dump:
108+
print('[-] Repo Name :: {} \n[-] Stars :: {} \n[-] Forks :: {} \n[-] Clone URL :: {}\n'.format(
109+
bagh['name'], bagh['stargazers_count'], bagh['forks_count'], bagh['clone_url']))
110+
111+
total_star, total_fork = 0, 0
112+
for bagh in repo_dump:
113+
total_star += int(bagh['stargazers_count'])
114+
total_fork += int(bagh['forks_count'])
115+
116+
print('[-] Total Stars : '+str(total_star))
117+
print('[-] Total Forks : '+str(total_fork))
118+
print('')
119+
else:
120+
pass
121+
122+
note = """
123+
GithubStat (c) Tahmid Rayat <https://github.com/htr-tech>
124+
125+
A Simple Github User Statistics Meter based on Github-API.
126+
127+
Type GithubStat <your github username>
128+
129+
Example : GithubStat HTR-TECH
130+
131+
If you Like this Project then don't Forget to leave a Star :)
132+
"""
133+
134+
def main():
135+
if len(sys.argv) >= 2:
136+
try:
137+
stats(sys.argv[1])
138+
except Exception as exceptions:
139+
sys.exit(exceptions)
140+
else:
141+
sys.exit(note)
142+
143+
if __name__ == '__main__':
144+
main()

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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 <github-username>
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 <github-username>
39+
```
40+
41+
***Copyright (c) 2021 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+

setup.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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.0",
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+
],
22+
packages = find_packages(),
23+
zip_safe = True,
24+
install_requires = ["requests >= 2.25.0", "six >= 1.13.0"],
25+
entry_points = {
26+
'console_scripts': [
27+
'GithubStat=GithubStat.__init__:main',
28+
'githubstat=GithubStat.__init__:main',
29+
'Gitstat=GithubStat.__init__:main',
30+
'gitstat=GithubStat.__init__:main',
31+
]
32+
}
33+
)
34+

0 commit comments

Comments
 (0)