Init
This commit is contained in:
commit
50bc9e60c7
20
LICENSE
Normal file
20
LICENSE
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2020 ATHUL CYRIAC AJAY
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
13
Pipfile
Normal file
13
Pipfile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[[source]]
|
||||||
|
name = "pypi"
|
||||||
|
url = "https://pypi.org/simple"
|
||||||
|
verify_ssl = true
|
||||||
|
|
||||||
|
[dev-packages]
|
||||||
|
|
||||||
|
[packages]
|
||||||
|
requests = "*"
|
||||||
|
pygithub = "*"
|
||||||
|
|
||||||
|
[requires]
|
||||||
|
python_version = "3.7"
|
85
Pipfile.lock
generated
Normal file
85
Pipfile.lock
generated
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
{
|
||||||
|
"_meta": {
|
||||||
|
"hash": {
|
||||||
|
"sha256": "ee0dbc310e64a4cc599d6b5e02bb22e3f33eb97ead8e5f1e315cf355fbef9367"
|
||||||
|
},
|
||||||
|
"pipfile-spec": 6,
|
||||||
|
"requires": {
|
||||||
|
"python_version": "3.7"
|
||||||
|
},
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"name": "pypi",
|
||||||
|
"url": "https://pypi.org/simple",
|
||||||
|
"verify_ssl": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"default": {
|
||||||
|
"certifi": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:5930595817496dd21bb8dc35dad090f1c2cd0adfaf21204bf6732ca5d8ee34d3",
|
||||||
|
"sha256:8fc0819f1f30ba15bdb34cceffb9ef04d99f420f68eb75d901e9560b8749fc41"
|
||||||
|
],
|
||||||
|
"version": "==2020.6.20"
|
||||||
|
},
|
||||||
|
"chardet": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
|
||||||
|
"sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"
|
||||||
|
],
|
||||||
|
"version": "==3.0.4"
|
||||||
|
},
|
||||||
|
"deprecated": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:525ba66fb5f90b07169fdd48b6373c18f1ee12728ca277ca44567a367d9d7f74",
|
||||||
|
"sha256:a766c1dccb30c5f6eb2b203f87edd1d8588847709c78589e1521d769addc8218"
|
||||||
|
],
|
||||||
|
"version": "==1.2.10"
|
||||||
|
},
|
||||||
|
"idna": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6",
|
||||||
|
"sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"
|
||||||
|
],
|
||||||
|
"version": "==2.10"
|
||||||
|
},
|
||||||
|
"pygithub": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:8375a058ec651cc0774244a3bc7395cf93617298735934cdd59e5bcd9a1df96e",
|
||||||
|
"sha256:d2d17d1e3f4474e070353f201164685a95b5a92f5ee0897442504e399c7bc249"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==1.51"
|
||||||
|
},
|
||||||
|
"pyjwt": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:5c6eca3c2940464d106b99ba83b00c6add741c9becaec087fb7ccdefea71350e",
|
||||||
|
"sha256:8d59a976fb773f3e6a39c85636357c4f0e242707394cadadd9814f5cbaa20e96"
|
||||||
|
],
|
||||||
|
"version": "==1.7.1"
|
||||||
|
},
|
||||||
|
"requests": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b",
|
||||||
|
"sha256:fe75cc94a9443b9246fc7049224f75604b113c36acb93f87b80ed42c44cbb898"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==2.24.0"
|
||||||
|
},
|
||||||
|
"urllib3": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:3018294ebefce6572a474f0604c2021e33b3fd8006ecd11d62107a5d2a963527",
|
||||||
|
"sha256:88206b0eb87e6d677d424843ac5209e3fb9d0190d0ee169599165ec25e9d9115"
|
||||||
|
],
|
||||||
|
"version": "==1.25.9"
|
||||||
|
},
|
||||||
|
"wrapt": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec1eb88e6d9b97d7"
|
||||||
|
],
|
||||||
|
"version": "==1.12.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"develop": {}
|
||||||
|
}
|
20
README.md
Normal file
20
README.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Dev Metrics in Readme
|
||||||
|
|
||||||
|
[Wakatime](https://wakatime.com) Weekly Metrics on your Profile Readme
|
||||||
|
|
||||||
|
## How to get it
|
||||||
|
**You Need to Have [waka-box](https://github.com/matchai/waka-box) in your Repo**
|
||||||
|
> *This maybe temporary and will be updated soon as I'll update this to an Action*
|
||||||
|
|
||||||
|
- Clone the Repo
|
||||||
|
- Install the dependencies `pip install -r requirements.txt`
|
||||||
|
- Get a GitHub Access Token with a `repo` scope
|
||||||
|
- Load env vars like
|
||||||
|
|
||||||
|
```text
|
||||||
|
GH_TOKEN = <ghtoken>
|
||||||
|
GIST_ID = <gist_id of the waka-box gist>
|
||||||
|
USERNAME = <github_username>
|
||||||
|
```
|
||||||
|
|
||||||
|
- Run the Script with `python main.py`
|
36
main.py
Normal file
36
main.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import base64
|
||||||
|
import requests
|
||||||
|
import re
|
||||||
|
import os
|
||||||
|
from github import Github
|
||||||
|
|
||||||
|
START_COMMENT = '<!--START_SECTION:waka-->'
|
||||||
|
END_COMMENT = '<!--END_SECTION:waka-->'
|
||||||
|
listReg = f'{START_COMMENT}[\\s\\S]+{END_COMMENT}'
|
||||||
|
|
||||||
|
user = os.getenv("USERNAME")
|
||||||
|
gistid = os.getenv("GIST_ID")
|
||||||
|
ghtoken = os.getenv("GH_TOKEN")
|
||||||
|
|
||||||
|
def getStats():
|
||||||
|
data = requests.get(f"https://gist.githubusercontent.com/{user}/{gistid}/raw/").text
|
||||||
|
return ("```text\n"+data+"\n```")
|
||||||
|
|
||||||
|
def decodeReadme(data:str):
|
||||||
|
decodedBytes = base64.b64decode(data)
|
||||||
|
decodedStr = str(decodedBytes, "utf-8")
|
||||||
|
return decodedStr
|
||||||
|
|
||||||
|
def generatenewReadme(stats:str,readme:str):
|
||||||
|
statsinReadme = f"{START_COMMENT}\n{stats}\n{END_COMMENT}"
|
||||||
|
newReadme = re.sub(listReg,statsinReadme,readme)
|
||||||
|
return newReadme
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
g = Github(ghtoken)
|
||||||
|
repo = g.get_repo(f"{user}/{user}")
|
||||||
|
contents = repo.get_readme()
|
||||||
|
stats = getStats()
|
||||||
|
rdmd = decodeReadme(contents.content)
|
||||||
|
newreadme = generatenewReadme(stats=stats,readme=rdmd)
|
||||||
|
repo.update_file(path=contents.path,message="Updated with Dev Metrics",content=newreadme,sha=contents.sha,branch="master")
|
9
requirements.txt
Normal file
9
requirements.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
certifi==2020.6.20
|
||||||
|
chardet==3.0.4
|
||||||
|
Deprecated==1.2.10
|
||||||
|
idna==2.10
|
||||||
|
PyGithub==1.51
|
||||||
|
PyJWT==1.7.1
|
||||||
|
requests==2.24.0
|
||||||
|
urllib3==1.25.9
|
||||||
|
wrapt==1.12.1
|
Loading…
x
Reference in New Issue
Block a user