Fix typos and add codespell to nox

This commit is contained in:
Kian-Meng Ang 2022-10-15 17:12:10 +08:00
parent 26635f0bd3
commit 1986a95063
10 changed files with 32 additions and 16 deletions

View File

@ -112,7 +112,7 @@ Changelog
* WEBP (lossy and lossless) images supported as output format * WEBP (lossy and lossless) images supported as output format
* PNG default optimization preset changed to a 10× faster preset (old preset * PNG default optimization preset changed to a 10× faster preset (old preset
stil available with ``--png-slow-optimization`` flag) still available with ``--png-slow-optimization`` flag)
* New model flag ``--no-fix-infacing-normals`` to disable Assimp's "fix * New model flag ``--no-fix-infacing-normals`` to disable Assimp's "fix
infacing normals" postprocess (#32, #33) infacing normals" postprocess (#32, #33)
* Show CLI usage when no parameter given * Show CLI usage when no parameter given
@ -136,7 +136,7 @@ Changelog
* **0.10.1:** * **0.10.1:**
* Fixes an issue that occures when output file does not already exist * Fixes an issue that occurs when output file does not already exist
* **0.10.0:** * **0.10.0:**

View File

@ -78,8 +78,8 @@ Resize Output Image
YOGA allows you to resize images with the ``--resize`` option:: YOGA allows you to resize images with the ``--resize`` option::
yoga image --resize=512 input.png ouput.png yoga image --resize=512 input.png output.png
yoga image --resize=512x512 input.png ouput.png yoga image --resize=512x512 input.png output.png
.. NOTE:: .. NOTE::

View File

@ -108,9 +108,10 @@ Libraries:
Development tools: Development tools:
* Black_: Code formater * Black_: Code formatter
* Flake8_: Linter * Flake8_: Linter
* Pytest_: Unit test * Pytest_: Unit test
* Codespell_: Code spell
Documentation: Documentation:
@ -258,5 +259,6 @@ Then you can run the following command::
.. _Flake8: https://flake8.pycqa.org/en/latest/ .. _Flake8: https://flake8.pycqa.org/en/latest/
.. _Black: https://black.readthedocs.io/en/stable/ .. _Black: https://black.readthedocs.io/en/stable/
.. _pytest: https://docs.pytest.org/ .. _pytest: https://docs.pytest.org/
.. _Codespell: https://github.com/codespell-project/codespell
.. _Sphinx: https://www.sphinx-doc.org/en/master/ .. _Sphinx: https://www.sphinx-doc.org/en/master/

View File

@ -11,7 +11,7 @@ PYTHON_FILES = [
@nox.session(reuse_venv=True) @nox.session(reuse_venv=True)
def lint(session): def lint(session):
session.install("flake8", "black") session.install("flake8", "black", "codespell")
session.run("flake8", *PYTHON_FILES) session.run("flake8", *PYTHON_FILES)
session.run( session.run(
"black", "black",
@ -21,6 +21,19 @@ def lint(session):
"--color", "--color",
*PYTHON_FILES, *PYTHON_FILES,
) )
session.run(
"codespell",
"-L",
"ans,alph",
"doc/",
"scripts/",
"test/",
"winbuild/",
"yoga/",
"noxfile.py",
"README.rst",
"setup.py",
)
@nox.session(reuse_venv=True) @nox.session(reuse_venv=True)

View File

@ -98,8 +98,9 @@ setup(
"flake8", "flake8",
"black", "black",
"pytest", "pytest",
"Sphinx", "sphinx",
"sphinx-rtd-theme", "sphinx-rtd-theme",
"codespell",
] ]
}, },
entry_points={ entry_points={

View File

@ -46,7 +46,7 @@ class Test_normalize_options(object):
with pytest.raises(IOError): with pytest.raises(IOError):
opt = options.normalize_options( opt = options.normalize_options(
{"fallback_texture": "non-existant.jpg"} {"fallback_texture": "non-existent.jpg"}
) )
def test_no_graph_optimization(self): def test_no_graph_optimization(self):

View File

@ -35,7 +35,7 @@ def python_int_to_big_endian_uint32_bytes(number):
def get_png_structure(data): def get_png_structure(data):
if not is_png(data): if not is_png(data):
raise ValueError("Unvalid PNG: Not a PNG file") raise ValueError("Invalid PNG: Not a PNG file")
result = { result = {
"size": len(data), "size": len(data),
@ -86,7 +86,7 @@ def get_IHDR_info(data):
def assemble_png_from_chunks(chunks): def assemble_png_from_chunks(chunks):
"""Assemble a PNG file from a list of chunks """Assemble a PNG file from a list of chunks
:param list chunks: The list of chunks (see bellow). :param list chunks: The list of chunks (see below).
Example list of chunk:: Example list of chunk::

View File

@ -8,7 +8,7 @@ def little_endian_unint32_bytes_to_python_int(bytes_):
def get_riff_structure(data): def get_riff_structure(data):
if data[0:4] != b"RIFF": if data[0:4] != b"RIFF":
raise ValueError("Unvalid RIFF: Not a RIFF file") raise ValueError("Invalid RIFF: Not a RIFF file")
result = { result = {
"formtype": data[8:12].decode(), "formtype": data[8:12].decode(),
@ -17,7 +17,7 @@ def get_riff_structure(data):
} }
if result["size"] + 8 != len(data): if result["size"] + 8 != len(data):
raise ValueError("Unvalid RIFF: Truncated data") raise ValueError("Invalid RIFF: Truncated data")
offset = 12 # RIFF header length offset = 12 # RIFF header length
@ -46,7 +46,7 @@ def get_vp8x_info(data):
# fmt: on # fmt: on
if len(data) != 10: if len(data) != 10:
ValueError("Invaild VP8X data") ValueError("Invalid VP8X data")
return { return {
"has_icc": bool(data[0] & VP8X_FLAG_ICC), "has_icc": bool(data[0] & VP8X_FLAG_ICC),

View File

@ -198,7 +198,7 @@ def optimize(
:param str,file-like input_file: The input model file. :param str,file-like input_file: The input model file.
:param str,file-like output_file: The output model file. :param str,file-like output_file: The output model file.
:param dict options: Optimization options (see above). :param dict options: Optimization options (see above).
:param dict textures: A dictionnary that maps textures path to bytes. When :param dict textures: A dictionary that maps textures path to bytes. When
not ``None``, there will be no file system reads in not ``None``, there will be no file system reads in
order to find referenced textures. YOGA will look order to find referenced textures. YOGA will look
into that dictionary instead. into that dictionary instead.
@ -246,7 +246,7 @@ def optimize(
) )
# Embed images # Embed images
# @note We save the bytes to a dictionnary so that the garbage collector # @note We save the bytes to a dictionary so that the garbage collector
# does not occur before exporting the scene a bit later # does not occur before exporting the scene a bit later
images_bytes = {} images_bytes = {}
model_embed_images( model_embed_images(

View File

@ -176,6 +176,6 @@ def model_embed_images(
optimized_textures[valid_image_path] = image optimized_textures[valid_image_path] = image
image = image.next image = image.next
# @note Save the bytes to a dictionnary so that the garbage collector # @note Save the bytes to a dictionary so that the garbage collector
# does not occur before exporting the scene a bit later # does not occur before exporting the scene a bit later
images_bytes[valid_image_path] = image_bytes_c images_bytes[valid_image_path] = image_bytes_c