Skip to content

Commit

Permalink
Merge pull request #120 from joe733/workshop
Browse files Browse the repository at this point in the history
feat: bumped version to 0.1.9
  • Loading branch information
yozachar authored Mar 25, 2023
2 parents 60fe3b9 + 60fa45f commit 59f35b0
Show file tree
Hide file tree
Showing 8 changed files with 346 additions and 232 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ celerybeat.pid
*.sage.py

# Environments
.env
*.env
.venv
env/
venv/
Expand Down
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing

![python_ver](https://img.shields.io/badge/python-%5E3.10-blue.svg)
![python_ver](https://img.shields.io/badge/Python-%5E3.11-blue.svg)

> First off, thank you! Please follow along.
Expand Down Expand Up @@ -71,8 +71,8 @@
```console
# poetry shell
# set -a && . ./.env && set +a # optional
(venv)# python -m main --dev
(venv)# python -m unittest discover # run tests
(waka-readme-py3_11)# python -m main --dev
(waka-readme-py3_11)# python -m unittest discover # run tests
```

5. Later, to remove stop and remove the container:
Expand Down Expand Up @@ -111,7 +111,7 @@
```console
$ poetry shell
(venv)$ poetry install
(waka-readme-py3_11)$ poetry install
```
to create and activate a virtual environnement and install dependencies.
Expand All @@ -136,7 +136,7 @@
3. Execute program in development mode with:

```console
$ set -a && . ./.env && set +a # optional
(venv)$ python -m main --dev
(venv)$ python -m unittest discover # run tests
(waka-readme-py3_11)$ set -a && . ./.env && set +a # optional
(waka-readme-py3_11)$ python -m main --dev
(waka-readme-py3_11)$ python -m unittest discover # run tests
```
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

</center>

# Dev Metrics in Readme [![Unit Tests](https://github.com/athul/waka-readme/actions/workflows/testing.yml/badge.svg?branch=master)](https://github.com/athul/waka-readme/actions/workflows/testing.yml) ![Python Version](https://img.shields.io/badge/python-v3.11-blue)
# Dev Metrics in Readme [![Unit Tests](https://github.com/athul/waka-readme/actions/workflows/testing.yml/badge.svg?branch=master)](https://github.com/athul/waka-readme/actions/workflows/testing.yml) ![Python Version](https://img.shields.io/badge/Python-^3.11-blue)

[WakaTime](https://wakatime.com) weekly metrics on your profile readme.

Expand Down Expand Up @@ -37,7 +37,7 @@ A GitHub repository and a `README.md` file is required. We'll be making use of r
<!--END_SECTION:waka-->
```

"`waka`" can be replaced by any alphanumeric string with the `SECTION_NAME` environment variable. See the [#tweaks](#tweaks) section for more.
`<!--START_SECTION: -->` and `<!--END_SECTION: -->` are placeholders and must be retained as is. Whereas "`waka`" can be replaced by any alphanumeric string. See [#Tweaks](#tweaks) section for more.

- Navigate to your repo's `Settings > Secrets` and add a new secret _named_ `WAKATIME_API_KEY` with your API key as it's _value_.

Expand Down
2 changes: 1 addition & 1 deletion containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ENV PYTHONFAULTHANDLER=1 \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
# poetry:
# POETRY_VERSION=1.1.14 \
# POETRY_VERSION= \
POETRY_NO_INTERACTION=1 \
POETRY_CACHE_DIR=/var/cache/pypoetry \
PATH=${PATH}:/root/.local/bin
Expand Down
2 changes: 1 addition & 1 deletion dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ENV PYTHONFAULTHANDLER=1 \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
# poetry:
# POETRY_VERSION=1.1.14 \
# POETRY_VERSION= \
POETRY_NO_INTERACTION=1 \
POETRY_CACHE_DIR=/var/cache/pypoetry \
PATH=${PATH}:/root/.local/bin
Expand Down
31 changes: 17 additions & 14 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
################### lib-func ###################


def strtobool(val: str | bool) -> bool:
def strtobool(val: str | bool):
"""
strtobool
---------
Expand All @@ -100,8 +100,8 @@ def strtobool(val: str | bool) -> bool:
Converts a string representation of truth to True or False.
- True values are `'y', 'yes', 't', 'true', 'on', and '1'`
- False values are `'n', 'no', 'f', 'false', 'off', and '0'`
- True values are `'y', 'yes', 't', 'true', 'on', and '1'`.
- False values are `'n', 'no', 'f', 'false', 'off', and '0'`.
- Raises `ValueError` if `val` is anything else.
"""
if isinstance(val, bool):
Expand Down Expand Up @@ -156,7 +156,7 @@ class WakaInput:
show_masked_time: str | bool = os.getenv('INPUT_SHOW_MASKED_TIME') or False
language_count: str | int = os.getenv('INPUT_LANG_COUNT') or 5

def validate_input(self) -> bool:
def validate_input(self):
"""
Validate Input Env Variables
----------------------------
Expand Down Expand Up @@ -214,7 +214,7 @@ def validate_input(self) -> bool:
################### logic ###################


def make_title(dawn: str | None, dusk: str | None, /) -> str:
def make_title(dawn: str | None, dusk: str | None, /):
"""
WakaReadme Title
----------------
Expand All @@ -237,7 +237,7 @@ def make_title(dawn: str | None, dusk: str | None, /) -> str:
return f'From: {start_date} - To: {end_date}'


def make_graph(block_style: str, percent: float, gr_len: int, lg_nm: str = '', /) -> str:
def make_graph(block_style: str, percent: float, gr_len: int, lg_nm: str = '', /):
"""
WakaReadme Graph
----------------
Expand All @@ -258,12 +258,12 @@ def make_graph(block_style: str, percent: float, gr_len: int, lg_nm: str = '', /
return graph_bar


def prep_content(stats: dict[str, Any], language_count: int = 5, /) -> str:
def prep_content(stats: dict[str, Any], language_count: int = 5, /):
"""
WakaReadme Prepare Markdown
---------------------------
Prepared markdown content from the fetched statistics
Prepared markdown content from the fetched statistics.
```
"""
logger.debug('Making contents')
Expand Down Expand Up @@ -319,12 +319,12 @@ def prep_content(stats: dict[str, Any], language_count: int = 5, /) -> str:
return contents.rstrip('\n')


def fetch_stats() -> dict[str, Any] | None:
def fetch_stats():
"""
WakaReadme Fetch Stats
----------------------
Returns statistics as JSON string
Returns statistics as JSON string.
"""
attempts = 4
statistic: dict[str, dict[str, Any]] = {}
Expand Down Expand Up @@ -368,12 +368,12 @@ def fetch_stats() -> dict[str, Any] | None:
return statistic.get('data')


def churn(old_readme: str, /) -> str | None:
def churn(old_readme: str, /):
"""
WakaReadme Churn
----------------
Composes WakaTime stats within markdown code snippet
Composes WakaTime stats within markdown code snippet.
"""
# check if placeholder pattern exists in readme
if not re.findall(wk_i.waka_block_pattern, old_readme):
Expand Down Expand Up @@ -406,8 +406,11 @@ def churn(old_readme: str, /) -> str | None:
return None if new_readme == old_readme else new_readme


def genesis() -> None:
"""Run Program"""
def genesis():
"""
Run Program
-----------
"""
logger.debug('Connecting to GitHub')
gh_connect = Github(wk_i.gh_token)
# since a validator is being used casting to string here is okay
Expand Down
Loading

0 comments on commit 59f35b0

Please sign in to comment.