Skip to content

Commit

Permalink
Major refactoring using ruff linter
Browse files Browse the repository at this point in the history
  • Loading branch information
mtouzot committed Jan 28, 2025
1 parent 38b139a commit 172621b
Show file tree
Hide file tree
Showing 28 changed files with 140 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
paths:
- .github/workflows/gh-pages.yml
- docs/**
- GameBEye/**
- gamebeye/**
- examples/**

jobs:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# GameBEye
# gamebeye

> GameBEye is a **Python Library** to process [Game Boy Camera](https://en.wikipedia.org/wiki/Game_Boy_Camera) images.
> gamebeye is a **Python Library** to process [Game Boy Camera](https://en.wikipedia.org/wiki/Game_Boy_Camera) images.

- **Source code** 📁: [https://github.com/mtouzot/GameBEye](https://github.com/mtouzot/GameBEye)
- **Issues** 🆘: [https://github.com/mtouzot/GameBEye/issues](https://github.com/mtouzot/GameBEye/issues)
- **Source code** 📁: [https://github.com/mtouzot/gamebeye](https://github.com/mtouzot/gamebeye)
- **Issues** 🆘: [https://github.com/mtouzot/gamebeye/issues](https://github.com/mtouzot/gamebeye/issues)

## 📜 Description

Expand Down
10 changes: 5 additions & 5 deletions docs/GameBEye.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
GameBEye documentation
gamebeye documentation
======================

.. automodule:: GameBEye
.. automodule:: gamebeye
:members:
:undoc-members:
:show-inheritance:

.. toctree::
:maxdepth: 4

./GameBEye/image.rst
./GameBEye/colors.rst
./GameBEye/filters.rst
./gamebeye/image.rst
./gamebeye/colors.rst
./gamebeye/filters.rst
12 changes: 6 additions & 6 deletions docs/GameBEye/colors.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Colors module
=============

The **GameBEye.gbcamcolors** module is as its name indicates focused on colors and color space conversion. It deals with a selection of color palettes (picked and adapted from `HerrZatacke <https://github.com/HerrZatacke>`_ `gb-printer-web <https://github.com/HerrZatacke/gb-printer-web>`_).
The **gamebeye.gbcamcolors** module is as its name indicates focused on colors and color space conversion. It deals with a selection of color palettes (picked and adapted from `HerrZatacke <https://github.com/HerrZatacke>`_ `gb-printer-web <https://github.com/HerrZatacke/gb-printer-web>`_).

Thoses colors allowed me to make this small animation :

Expand All @@ -14,24 +14,24 @@ Thoses colors allowed me to make this small animation :
<p>Animated GIF made of colorized images</p>
</div>

:mod:`GameBEye.gbcamcolors` module
:mod:`gamebeye.gbcamcolors` module
----------------------------------

This module also uses methods from :ref:`ch module`

.. automodule:: GameBEye.gbcamcolors
.. automodule:: gamebeye.gbcamcolors

.. autoclass:: GameBEye.gbcamcolors.GBColorPalettes
.. autoclass:: gamebeye.gbcamcolors.GBColorPalettes
:members:
:undoc-members:
:show-inheritance:

.. _ch module:

:mod:`GameBEye.color\_helpers` module
:mod:`gamebeye.color\_helpers` module
-------------------------------------

.. automodule:: GameBEye.color_helpers
.. automodule:: gamebeye.color_helpers
:members:
:undoc-members:
:show-inheritance:
6 changes: 3 additions & 3 deletions docs/GameBEye/filters.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Filters module
===================

The **GameBEye.gbcamfilters** module is as its name indicates focused on filters. It is used to *play* with :mod:`GameBEye.gbcamimage.GBCamImage`
The **gamebeye.gbcamfilters** module is as its name indicates focused on filters. It is used to *play* with :mod:`gamebeye.gbcamimage.GBCamImage`

:mod:`GameBEye.gbcamfilters` module
:mod:`gamebeye.gbcamfilters` module
------------------------------------------------

.. automodule:: GameBEye.gbcamfilters
.. automodule:: gamebeye.gbcamfilters
:members:
:undoc-members:
:show-inheritance:
4 changes: 2 additions & 2 deletions docs/GameBEye/image.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Image module
============

The **GameBEye.gbcamimage** module is as its name indicates focused on Game Boy Camera image.
The **gamebeye.gbcamimage** module is as its name indicates focused on Game Boy Camera image.

Each borderless image has a *128x112* pixels resolution and uses a 4-color palette (grayscale values, natively).

.. automodule:: GameBEye.gbcamimage
.. automodule:: gamebeye.gbcamimage
:members:
:undoc-members:
:show-inheritance:
5 changes: 3 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import importlib.metadata
import os
import sys
import importlib.metadata

sys.path.insert(0, os.path.abspath(".."))


# -- Project information -----------------------------------------------------
project = "GameBEye"
project = "gamebeye"
copyright = "2021 - 2025, Martin TOUZOT"
author = "Martin TOUZOT"

Expand Down Expand Up @@ -93,6 +93,7 @@
"icon/apple-touch-icon.png",
]


# Add custom CSS file
def setup(app):
app.add_css_file("css/custom.css")
2 changes: 1 addition & 1 deletion docs/examples.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Examples
========

You can find more usages of **GameBEye** library in the `examples <https://github.com/mtouzot/GameBEye/tree/master/examples>`_ folder.
You can find more usages of **gamebeye** library in the `examples <https://github.com/mtouzot/gamebeye/tree/master/examples>`_ folder.

Among others, you'll be able to create an animated GIF made of color Game Boy Camera images.

Expand Down
4 changes: 2 additions & 2 deletions docs/examples/colorizing_image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ You'll see in this example the result of updating the color palette of an origin
"""An example to change image color palette from BW to AZC."""
from GameBEye.gbcamimage import GBCamImage
from GameBEye.gbcamcolors import GBColorPalettes
from gamebeye.gbcamimage import GBCamImage
from gamebeye.gbcamcolors import GBColorPalettes
import cv2
# Path to the image
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/display_images.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Display image and its color palette in a second window
"""An example to display both image and its corresponding color palette."""
from GameBEye.gbcamimage import GBCamImage
from GameBEye.color_helpers import hex_to_rgb
from gamebeye.gbcamimage import GBCamImage
from gamebeye.color_helpers import hex_to_rgb
import numpy as np
import cv2
import os
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/printing_image.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ here's an example of how looks a printed image
"""An example to use the thermal printer effect on an image."""
from GameBEye.gbcamimage import GBCamImage
import GameBEye.gbcamfilters as gbcamfilters
from gamebeye.gbcamimage import GBCamImage
import gamebeye.gbcamfilters as gbcamfilters
import cv2
# Path to the image
Expand Down
22 changes: 11 additions & 11 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Welcome to GameBEye's documentation!
Welcome to gamebeye's documentation!
====================================

|Github| |License| |Issues| |Release|

GameBEye is a **Python library** to process `Game Boy Camera <https://en.wikipedia.org/wiki/Game_Boy_Camera>`_ images.
gamebeye is a **Python library** to process `Game Boy Camera <https://en.wikipedia.org/wiki/Game_Boy_Camera>`_ images.

Here are what a Game Boy camera can capture:

Expand Down Expand Up @@ -50,7 +50,7 @@ Here are some infos about the hardware and the Gam Boy Camera images that drive

./hardware.rst
./installation.rst
./GameBEye.rst
./gamebeye.rst
./examples.rst

Indices and tables
Expand All @@ -60,17 +60,17 @@ Indices and tables
* :ref:`modindex`
* :ref:`search`

.. |Github| image:: https://img.shields.io/github/stars/mtouzot/GameBEye?label=Github&logo=github
:target: https://github.com/mtouzot/GameBEye
.. |Github| image:: https://img.shields.io/github/stars/mtouzot/gamebeye?label=Github&logo=github
:target: https://github.com/mtouzot/gamebeye

.. |License| image:: https://img.shields.io/github/license/mtouzot/GameBEye
:target: https://github.com/mtouzot/GameBEye/blob/master/LICENSE
.. |License| image:: https://img.shields.io/github/license/mtouzot/gamebeye
:target: https://github.com/mtouzot/gamebeye/blob/master/LICENSE

.. |Issues| image:: https://img.shields.io/github/issues/mtouzot/GameBEye
:target: https://github.com/mtouzot/GameBEye/issues
.. |Issues| image:: https://img.shields.io/github/issues/mtouzot/gamebeye
:target: https://github.com/mtouzot/gamebeye/issues

.. |Release| image:: https://img.shields.io/github/v/release/mtouzot/GameBEye
:target: https://github.com/mtouzot/GameBEye/releases
.. |Release| image:: https://img.shields.io/github/v/release/mtouzot/gamebeye
:target: https://github.com/mtouzot/gamebeye/releases

.. |BWpalette| image:: ./_static/colorPalettes/BW.png
:class: align-center
Expand Down
4 changes: 2 additions & 2 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ From sources

The sources can be downloaded from the GitHub repository::

git clone https://github.com/mtouzot/GameBEye.git
cd GameBEye
git clone https://github.com/mtouzot/gamebeye.git
cd gamebeye
3 changes: 2 additions & 1 deletion examples/01_reading_and_displaying_an_image.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""An example to show an image, to log its name and color palette."""

from GameBEye.gbcamimage import GBCamImage
import cv2

from gamebeye.gbcamimage import GBCamImage

# Path to the image
image_filepath = "images\\originalImage.png"

Expand Down
9 changes: 4 additions & 5 deletions examples/02_changing_image_color.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""An example to change image color palette from BW to AZC."""

from GameBEye.gbcamimage import GBCamImage
from GameBEye.gbcamcolors import GBColorPalettes
import cv2

from gamebeye.gbcamcolors import GBColorPalettes
from gamebeye.gbcamimage import GBCamImage

# Path to the image
image_filepath = "images\\originalImage.png"
img = cv2.imread(image_filepath)
Expand All @@ -25,9 +26,7 @@
gb_img.change_color(color_palette=gb_color_palette)

# Displaying the colorized image
color_title = "Colorized image with {} color palette".format(
gb_img.color_palette.name
)
color_title = "Colorized image with {} color palette".format(gb_img.color_palette.name)
cv2.imshow(color_title, gb_img.data)
print(
"Colorized image color palette : {}\nRequired color palette : {}".format(
Expand Down
19 changes: 8 additions & 11 deletions examples/03_display_color_palette.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
"""An example to display both image and its corresponding color palette."""

from GameBEye.gbcamimage import GBCamImage
from GameBEye.color_helpers import hex_to_rgb
import numpy as np
import cv2
import os

import cv2
import numpy as np

from gamebeye.color_helpers import hex_to_rgb
from gamebeye.gbcamimage import GBCamImage

input_folder = os.path.join("images", "colorizedImages")
images_filepath = sorted(
[
os.path.join(input_folder, filename)
for filename in os.listdir(input_folder)
]
[os.path.join(input_folder, filename) for filename in os.listdir(input_folder)]
)

for image_filepath in images_filepath:
Expand All @@ -38,9 +37,7 @@
color_palettes.append(cv2.merge([blue, green, red]))
color_palettes = cv2.hconcat(color_palettes)

color_palette_title = "Color palettes {}".format(
gb_image.color_palette.name
)
color_palette_title = "Color palettes {}".format(gb_image.color_palette.name)
cv2.imshow(color_palette_title, color_palettes)

cv2.waitKey()
Expand Down
5 changes: 3 additions & 2 deletions examples/04_print_image_paper.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""An example to use the thermal printer effect on an image."""

from GameBEye.gbcamimage import GBCamImage
import GameBEye.gbcamfilters as gbcamfilters
import cv2

import gamebeye.gbcamfilters as gbcamfilters
from gamebeye.gbcamimage import GBCamImage

# Path to the image
image_filepath = "images\\originalImage.png"
img = cv2.imread(image_filepath)
Expand Down
3 changes: 2 additions & 1 deletion GameBEye/__init__.py → gamebeye/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide an object to manage Game Boy Camera images.
"""
Provide an object to manage Game Boy Camera images.
Allow to read and apply various filters on images capture with Game Boy Camera.
Expand Down
Loading

0 comments on commit 172621b

Please sign in to comment.