Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize CI, Update Dependencies, Confirm Support For Python 3.9-3.13 #7

Merged
merged 6 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Run Checks

on: [ push, pull_request, workflow_dispatch ]

jobs:
checks:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4

- name: Set up python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
run: curl -sSL https://install.python-poetry.org | python3 -

- name: Configure Poetry
run: poetry config virtualenvs.in-project true

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
run: poetry install

- name: Run Ruff linter
run: poetry run ruff check . --no-fix

- name: Run Ruff formatter
run: poetry run ruff format . --check
39 changes: 0 additions & 39 deletions .github/workflows/ci.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ MANIFEST.in
dist/
.venv/
.idea/
.ruff_cache/
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# To-Ascii ![Code Quality](https://www.codefactor.io/repository/github/iapetus-11/to-ascii/badge/master) ![PYPI Version](https://img.shields.io/pypi/v/to-ascii.svg) ![PYPI Downloads](https://img.shields.io/pypi/dw/to-ascii?color=0FAE6E)
# To-ASCII ![Code Quality](https://www.codefactor.io/repository/github/iapetus-11/to-ascii/badge/master) ![PYPI Version](https://img.shields.io/pypi/v/to-ascii.svg) ![PYPI Downloads](https://img.shields.io/pypi/dw/to-ascii?color=0FAE6E)
*Converts videos, images, gifs, and even live video into ascii art!*

* Works on most image and video types including GIFs
* Works on LIVE VIDEO
- Works on most image and video types including GIFs
- Works on LIVE VIDEO

<img src="https://user-images.githubusercontent.com/38477514/180253533-e0725ba5-6c6d-408d-a643-ff02f021cff8.png" width="360" /> <img src="https://user-images.githubusercontent.com/38477514/180254306-9e8eca93-ea38-47bf-b1c2-72ad75244604.png" width="360" /> <img src="https://user-images.githubusercontent.com/38477514/180251469-8826a23d-a292-42b2-83c6-c9a637214b5e.png" width="360" /> <img src="https://user-images.githubusercontent.com/38477514/180251666-49b07f5f-da3c-4790-85b9-ba72dbca606b.png" width="360" />

Expand Down
270 changes: 90 additions & 180 deletions poetry.lock

Large diffs are not rendered by default.

28 changes: 8 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "to-ascii"
version = "6.0.1"
version = "6.1.0"
description = "Convert videos, images, gifs, and even live video to ASCII art!"
authors = ["Milo Weinberg <[email protected]>"]
license = "MIT"
Expand All @@ -12,13 +12,13 @@ repository = "https://github.com/Iapetus-11/To-ASCII"
keywords = ["ascii", "color", "colors", "ascii-art", "video", "image", "nim"]

[tool.poetry.dependencies]
python = "^3.8"
numpy = "^1.23.1"
opencv-python = "^4.6.0"
colorama = "^0.4.5"
python = ">=3.9,<4.0"
numpy = "2.0"
opencv-python = "^4.10.0.84"
colorama = "^0.4.6"
nimporter = { version = "^1.1.0", optional = true}
pydantic = "^1.9.1"
click = { version = "^8.1.3", optional = true}
click = "^8.1.8"

[tool.poetry.extras]
speedups = ["nimporter"]
Expand All @@ -28,24 +28,12 @@ cli = ["click"]
toascii = "toascii.cli:toascii_command"

[tool.poetry.group.dev.dependencies]
isort = "^5.10.1"
black = "^22.8.0"
ruff = "^0.1.4"
ruff = "^0.9.1"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[tool.black]
line-length = 100
target-version = ['py38']
include = '\.pyi?$'

[tool.isort]
profile = "black"
line_length = 100

[tool.ruff]
line-length = 100
#ignore = ["E501", "E266", "E203", "E741", "W293", "W291"]
target-version = "py38"
target-version = "py39"
1 change: 1 addition & 0 deletions toascii/converters/color_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
COLOR_TRUNC = 128
COLOR_TRUNC_TO = 256 // COLOR_TRUNC


# generates all colors possible within the color space COLOR_TRUNC_TO
def _gen_colors() -> Generator[T_COLOR, None, None]:
for r in range(0, COLOR_TRUNC_TO):
Expand Down
2 changes: 1 addition & 1 deletion toascii/converters/html_color_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _asciify_image(self, image: np.ndarray) -> Generator[str, None, None]:
yield "</span>"

last_color = color
yield f"""<span style="color:rgb({','.join(map(str, color))})">"""
yield f"""<span style="color:rgb({",".join(map(str, color))})">"""

yield char

Expand Down
26 changes: 10 additions & 16 deletions toascii/media_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,43 +47,37 @@ def ensure_valid(self) -> None:

@property
@abc.abstractmethod
def is_live(self) -> bool:
...
def is_live(self) -> bool: ...

@property
@abc.abstractmethod
def fps(self) -> float:
...
def fps(self) -> float: ...

@property
@abc.abstractmethod
def width(self) -> int:
...
def width(self) -> int: ...

@property
@abc.abstractmethod
def height(self) -> int:
...
def height(self) -> int: ...

@property
@abc.abstractmethod
def frame_count(self) -> int:
...
def frame_count(self) -> int: ...

def __iter__(self) -> typing_extensions.Self:
return self

@abc.abstractmethod
def __next__(self) -> numpy.ndarray:
...
def __next__(self) -> numpy.ndarray: ...

@abc.abstractmethod
def __enter__(self) -> typing_extensions.Self:
...
def __enter__(self) -> typing_extensions.Self: ...

@abc.abstractmethod
def __exit__(self, exc_type: Type[BaseException], exc_val: BaseException, exc_tb: Any) -> None:
...
def __exit__(
self, exc_type: Type[BaseException], exc_val: BaseException, exc_tb: Any
) -> None: ...


class OpenCVVideoSource(AbstractVideoSource):
Expand Down
Loading