-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from justgigio/v0.0.2
V0.0.2
- Loading branch information
Showing
20 changed files
with
343 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: Build 🐍 | ||
on: push | ||
jobs: | ||
tests: | ||
uses: ./.github/workflows/tests.yml | ||
build: | ||
name: Build distribution 📦 | ||
needs: | ||
- tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.12" | ||
- name: Install pypa/build | ||
run: >- | ||
python3 -m | ||
pip install | ||
build | ||
--user | ||
- name: Build a binary wheel and a source tarball | ||
run: python3 -m build | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
publish-to-pypi: | ||
name: >- | ||
Publish Python 🐍 distribution 📦 to PyPI | ||
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/awesome_git_mosaic | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Publish distribution 📦 to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
github-release: | ||
name: >- | ||
Sign the Python 🐍 distribution 📦 with Sigstore | ||
and upload them to GitHub Release | ||
needs: | ||
- publish-to-pypi | ||
runs-on: ubuntu-latest | ||
|
||
permissions: | ||
contents: write # IMPORTANT: mandatory for making GitHub Releases | ||
id-token: write # IMPORTANT: mandatory for sigstore | ||
|
||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Sign the dists with Sigstore | ||
uses: sigstore/[email protected] | ||
with: | ||
inputs: >- | ||
./dist/*.tar.gz | ||
./dist/*.whl | ||
- name: Create GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
run: >- | ||
gh release create | ||
'${{ github.ref_name }}' | ||
--repo '${{ github.repository }}' | ||
--notes "" | ||
- name: Upload artifact signatures to GitHub Release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
# Upload to GitHub Release using the `gh` CLI. | ||
# `dist/` contains the built packages, and the | ||
# sigstore-produced signatures and certificates. | ||
run: >- | ||
gh release upload | ||
'${{ github.ref_name }}' dist/** | ||
--repo '${{ github.repository }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Test 🐍 | ||
on: [workflow_call] | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10", "3.11", "3.12"] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
# You can test your matrix by printing the current Python version | ||
- name: Display Python version | ||
run: python -c "import sys; print(sys.version)" | ||
- name: Install dependencies | ||
run: | | ||
python3 -m venv $POETRY_HOME | ||
$POETRY_HOME/bin/pip install poetry==1.7.0 | ||
$POETRY_HOME/bin/poetry --version | ||
$POETRY_HOME/bin/poetry install | ||
- name: Check Code style | ||
run: >- | ||
$POETRY_HOME/bin/poetry run pycodestyle --statistics --ignore=E501,W503,E902 --count src | ||
- name: Check MyPy | ||
run: >- | ||
$POETRY_HOME/bin/poetry run mypy src | ||
- name: Check Black | ||
run: >- | ||
$POETRY_HOME/bin/poetry run black --check src | ||
- name: Check isort | ||
run: >- | ||
$POETRY_HOME/bin/poetry run isort --ac --check-only src | ||
- name: Execute tests | ||
run: >- | ||
$POETRY_HOME/bin/poetry run py.test tests | ||
--cov=. | ||
--cov-report xml | ||
--cov-report term | ||
--cov-fail-under=90 | ||
- name: Upload coverage reports to Codecov | ||
uses: codecov/codecov-action@v3 | ||
env: | ||
POETRY_HOME: /opt/poetry | ||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,6 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
.awesome_folder | ||
.__testing_modify_folder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
[![codecov](https://codecov.io/gh/justgigio/awesome-git-mosaic/graph/badge.svg?token=0ON0YL8EAH)](https://codecov.io/gh/justgigio/awesome-git-mosaic) | ||
![build](https://github.com/justgigio/awesome-git-mosaic/actions/workflows/build.yml/badge.svg) | ||
- Pypi badge | ||
- python version badge | ||
- docs badge | ||
# awesome-git-mosaic | ||
A simple tool to make cool tricks with your GitHub activity mosaic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "awesome_git_mosaic" | ||
version = "0.0.1" | ||
version = "0.0.2" | ||
description = "An awesome tool to write small texts on GitHub mosaic" | ||
authors = ["Giovane Costa <[email protected]>"] | ||
license = "MIT License" | ||
|
@@ -26,3 +26,6 @@ build-backend = "poetry.core.masonry.api" | |
[[tool.mypy.overrides]] | ||
module = "unidecode,awesome_git_mosaic.*" | ||
ignore_missing_imports = true | ||
|
||
[tool.isort] | ||
line_length = 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
from awesome_git_mosaic.usecases.write_mosaic import WriteMosaic | ||
|
||
|
||
def write(text: str, strength: int = 5, multiply: int = 1, background: bool = False): | ||
WriteMosaic().write(text, strength, multiply, background) # pragma: no cover | ||
def write( | ||
text: str, | ||
strength: int = 5, | ||
multiply: int = 1, | ||
with_spaces: bool = True, | ||
background: bool = False, | ||
inverted: bool = False, | ||
): | ||
WriteMosaic().write( | ||
text, strength, multiply, with_spaces, background, inverted | ||
) # pragma: no cover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 18 additions & 10 deletions
28
src/awesome_git_mosaic/adapters/console/console_adapter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,35 @@ | ||
from typing import TYPE_CHECKING, Optional | ||
|
||
from awesome_git_mosaic.charmaps.basic.basic_charmap import BasicCharmap | ||
from typing import Optional, TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from awesome_git_mosaic.charmaps.charmap import Charmap | ||
|
||
|
||
CONSOLE_PIXEL = '▉' | ||
CONSOLE_SPACE = ' ' | ||
CONSOLE_PIXEL = "▉" | ||
CONSOLE_SPACE = " " | ||
CONSOLE_BG = "░" | ||
|
||
|
||
class ConsoleAdapter: | ||
|
||
def __init__(self, charmap: Optional['Charmap'] = None): | ||
def __init__(self, charmap: Optional["Charmap"] = None): | ||
self.charmap = charmap or BasicCharmap() | ||
|
||
def output(self, message: str, with_spaces: bool = True) -> str: | ||
lines = self.charmap.translate(message, with_spaces) | ||
def output( | ||
self, | ||
message: str, | ||
with_spaces: bool = True, | ||
background: bool = False, | ||
inverted: bool = False, | ||
) -> str: | ||
lines = self.charmap.translate(message, with_spaces, inverted) | ||
|
||
bg = CONSOLE_BG if background else CONSOLE_SPACE | ||
output = [] | ||
for line in lines: | ||
output_line = '' | ||
output_line = "" | ||
for char in line: | ||
output_line += CONSOLE_PIXEL if self.charmap.is_pixel(char) else CONSOLE_SPACE | ||
output_line += CONSOLE_PIXEL if self.charmap.is_pixel(char) else bg | ||
output.append(output_line) | ||
|
||
return '\n'.join(output) | ||
return "\n".join(output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.