Skip to content

Commit e5eb779

Browse files
author
ravishhankar
committed
Initial Commit
1 parent 44cb099 commit e5eb779

File tree

209 files changed

+64049
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+64049
-0
lines changed

Diff for: GitProfile/__init__.py

Whitespace-only changes.

Diff for: GitProfile/asgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for GitProfile project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'GitProfile.settings')
15+
16+
application = get_asgi_application()

Diff for: GitProfile/settings.py

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
"""
2+
Django settings for GitProfile project.
3+
4+
Generated by 'django-admin startproject' using Django 3.0.8.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.0/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/3.0/ref/settings/
11+
"""
12+
13+
import os
14+
15+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
17+
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = 'z%95+x^d@@9#=r64ypapgq=^c@vw-pt6&nxjl1djbhyx38-=$g'
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = True
27+
28+
ALLOWED_HOSTS = ['guarded-depths-55025.herokuapp.com','*']
29+
30+
31+
# Application definition
32+
33+
INSTALLED_APPS = [
34+
'django.contrib.admin',
35+
'django.contrib.auth',
36+
'django.contrib.contenttypes',
37+
'django.contrib.sessions',
38+
'django.contrib.messages',
39+
'django.contrib.staticfiles',
40+
'gprofile'
41+
]
42+
43+
MIDDLEWARE = [
44+
'django.middleware.security.SecurityMiddleware',
45+
'django.contrib.sessions.middleware.SessionMiddleware',
46+
'django.middleware.common.CommonMiddleware',
47+
'django.middleware.csrf.CsrfViewMiddleware',
48+
'django.contrib.auth.middleware.AuthenticationMiddleware',
49+
'django.contrib.messages.middleware.MessageMiddleware',
50+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
51+
'whitenoise.middleware.WhiteNoiseMiddleware'
52+
]
53+
54+
ROOT_URLCONF = 'GitProfile.urls'
55+
56+
TEMPLATES = [
57+
{
58+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
59+
'DIRS': [],
60+
'APP_DIRS': True,
61+
'OPTIONS': {
62+
'context_processors': [
63+
'django.template.context_processors.debug',
64+
'django.template.context_processors.request',
65+
'django.contrib.auth.context_processors.auth',
66+
'django.contrib.messages.context_processors.messages',
67+
],
68+
},
69+
},
70+
]
71+
72+
WSGI_APPLICATION = 'GitProfile.wsgi.application'
73+
74+
75+
# Database
76+
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
77+
78+
DATABASES = {
79+
'default': {
80+
'ENGINE': 'django.db.backends.sqlite3',
81+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
82+
}
83+
}
84+
85+
86+
# Password validation
87+
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
88+
89+
AUTH_PASSWORD_VALIDATORS = [
90+
{
91+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
92+
},
93+
{
94+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
95+
},
96+
{
97+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
98+
},
99+
{
100+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
101+
},
102+
]
103+
104+
105+
# Internationalization
106+
# https://docs.djangoproject.com/en/3.0/topics/i18n/
107+
108+
LANGUAGE_CODE = 'en-us'
109+
110+
TIME_ZONE = 'UTC'
111+
112+
USE_I18N = True
113+
114+
USE_L10N = True
115+
116+
USE_TZ = True
117+
118+
119+
# Static files (CSS, JavaScript, Images)
120+
# https://docs.djangoproject.com/en/3.0/howto/static-files/
121+
122+
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
123+
STATIC_URL = '/static/'
124+
125+
# Extra places for collectstatic to find static files.
126+
STATICFILES_DIRS = (
127+
os.path.join(BASE_DIR, 'static'),
128+
)

Diff for: GitProfile/urls.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""GitProfile URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/3.0/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from django.contrib import admin
17+
from django.urls import path,include
18+
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
19+
urlpatterns = [
20+
path('admin/', admin.site.urls),
21+
path('',include('gprofile.urls')),
22+
]

Diff for: GitProfile/wsgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for GitProfile project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'GitProfile.settings')
15+
16+
application = get_wsgi_application()

Diff for: Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn GitProfile.wsgi

Diff for: README.md

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# GitProfile
2+
This is a simple utility tool, this will analyze public git profile
3+
4+
## Demo App
5+
visit [Here](https://guarded-depths-55025.herokuapp.com)
6+
### Install
7+
**Step 1.** Clone GitProfile Repository https://github.com/Python-World/GitProfile
8+
```
9+
git clone https://github.com/Python-World/GitProfile
10+
```
11+
12+
**Step 2.** Change Directory
13+
```
14+
cd GitProfile/
15+
```
16+
17+
**Step 3.** Install Required Packages
18+
```
19+
pip3 install -r requirements.txt
20+
```
21+
22+
**Step 4.** Configure github Access Token
23+
Follow steps from [Here](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) to get github access token
24+
25+
once you get github access token in `config.ini`
26+
```
27+
github_token:<AccessToken>
28+
```
29+
30+
**Step 5.** Now run the program by following command in any operating system of your choice :
31+
```
32+
pip install -r requirements.txt
33+
```
34+
## Demo
35+
<details>
36+
<summary>1)@tusharnankani</summary>
37+
38+
![Demo](media/tusharnankani.png)
39+
40+
</details>
41+
<details>
42+
<summary>2)@chavarera</summary>
43+
44+
![Demo](media/chavarera.png)
45+
</details>
46+
<details>
47+
<summary>3)@AdityaJ7</summary>
48+
49+
![Demo](media/AdityaJ7.png)
50+
</details>
51+
52+
53+
54+
## Suppport
55+
56+
If you facing any issue while executing create a issue [Here](https://github.com/Python-World/GitProfile/issues) and upload your problem with detailed description

Diff for: api/Connect.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from abc import ABC
2+
from github import Github
3+
from configparser import ConfigParser
4+
5+
6+
def get_config(section, keyword):
7+
config = ConfigParser()
8+
config.read('config.ini')
9+
token = config.get(section, keyword)
10+
return token
11+
12+
13+
class Connect(ABC):
14+
token = get_config('Auth', 'github_token')
15+
16+
conn = None
17+
try:
18+
conn = Github(token)
19+
except Exception as ex:
20+
pass

Diff for: api/GitUser.py

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
from lxml.html import fromstring
2+
from datetime import datetime
3+
from .Connect import Connect
4+
import requests
5+
import json
6+
7+
8+
class GitUser(Connect):
9+
def __init__(self, user):
10+
self.user = Connect.conn.get_user(user)
11+
self.username = self.user.login
12+
self.profile = self.user.html_url
13+
self.picture = self.user.avatar_url
14+
self.name = self.user.name
15+
self.email = self.user.email
16+
self.followers = self.user.followers
17+
self.following = self.user.following
18+
self.repos = self.user.public_repos
19+
self.gist = self.user.public_gists
20+
self.bio = self.user.bio
21+
self.blog = self.user.blog
22+
self.created = self.__get_date(self.user.created_at)
23+
self.modified = self.__get_date(self.user.updated_at)
24+
25+
def __get_date(self, date):
26+
return datetime.strftime(date, '%d-%b-%Y')
27+
28+
def get_user(self):
29+
return self.__dict__
30+
31+
def get_languages(self):
32+
language_contribution = {}
33+
try:
34+
req = requests.get(
35+
'https://github.com/search?q=user%3A{}'.format(self.username))
36+
response = fromstring(req.text,)
37+
languages = response.xpath('//a[contains(@href,"search?l=")]')
38+
for language in languages:
39+
lang = language.xpath('./text()')[-1].strip()
40+
total = language.xpath('./span/text()')[-1]
41+
language_contribution[lang] = total
42+
except Exception as ex:
43+
print(ex)
44+
return language_contribution
45+
46+
def get_overview(self):
47+
overview = {}
48+
try:
49+
req = requests.get('https://github.com/{}'.format(self.username))
50+
response = fromstring(req.text,)
51+
details = response.xpath(
52+
'//*[@class="js-activity-overview-graph-container"]/@data-percentages')
53+
details = details[0] if details else '{}'
54+
overview = json.loads(details)
55+
except Exception as ex:
56+
print(ex)
57+
return overview

Diff for: config.ini

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[Auth]
2+
github_token:<github access token>

Diff for: gprofile/__init__.py

Whitespace-only changes.

Diff for: gprofile/admin.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

Diff for: gprofile/apps.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class GprofileConfig(AppConfig):
5+
name = 'gprofile'

Diff for: gprofile/migrations/__init__.py

Whitespace-only changes.

Diff for: gprofile/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.db import models
2+
3+
# Create your models here.

0 commit comments

Comments
 (0)