Skip to content
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
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense

.py text eol=lf
.rst text eol=lf
.txt text eol=lf
.yaml text eol=lf
.toml text eol=lf
.license text eol=lf
.md text eol=lf
25 changes: 19 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
awk -F '\/' '{ print tolower($2) }' |
tr '_' '-'
)" >> $GITHUB_OUTPUT
- name: Set up Python 3.X
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.x'
python-version: '3.11'
- name: Versions
run: |
python3 --version
Expand All @@ -42,16 +42,29 @@ jobs:
# (e.g. - apt-get: gettext, etc; pip: circuitpython-build-tools, requirements.txt; etc.)
run: |
source actions-ci/install.sh
- name: Pip install pylint, Sphinx, pre-commit
- name: Pip install Sphinx, pre-commit
run: |
pip install --force-reinstall pylint Sphinx sphinx-rtd-theme pre-commit
pip install --force-reinstall Sphinx sphinx-rtd-theme pre-commit
- name: Library version
run: git describe --dirty --always --tags
- name: Setup problem matchers
uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1
- name: Pre-commit hooks
run: |
pre-commit run --all-files
- name: Build assets
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location .
- name: Build docs
working-directory: docs
run: sphinx-build -E -W -b html . _build/html
- name: Check For pyproject.toml
id: need-pypi
run: |
echo "pyproject-toml=$( find . -wholename './pyproject.toml' )" >> $GITHUB_OUTPUT
- name: Build Python package
if: contains(steps.need-pypi.outputs.pyproject-toml, 'pyproject.toml')
run: |
pip install --upgrade build twine
for file in $(find -not -path "./.*" -not -path "./docs*" \( -name "*.py" -o -name "*.toml" \) ); do
sed -i -e "s/0.0.0+auto.0/1.2.3/" $file;
done;
python -m build
twine check dist/*
50 changes: 40 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,48 @@
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
# SPDX-FileCopyrightText: 2022 Kattni Rembor, written for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense
# SPDX-License-Identifier: MIT

# Do not include files and directories created by your personal work environment, such as the IDE
# you use, except for those already listed here. Pull requests including changes to this file will
# not be accepted.

# This .gitignore file contains rules for files generated by working with CircuitPython libraries,
# including building Sphinx, testing with pip, and creating a virual environment, as well as the
# MacOS and IDE-specific files generated by using MacOS in general, or the PyCharm or VSCode IDEs.

# If you find that there are files being generated on your machine that should not be included in
# your git commit, you should create a .gitignore_global file on your computer to include the
# files created by your personal setup. To do so, follow the two steps below.

# First, create a file called .gitignore_global somewhere convenient for you, and add rules for
# the files you want to exclude from git commits.

# Second, configure Git to use the exclude file for all Git repositories by running the
# following via commandline, replacing "path/to/your/" with the actual path to your newly created
# .gitignore_global file:
# git config --global core.excludesfile path/to/your/.gitignore_global

# CircuitPython-specific files
*.mpy
.idea

# Python-specific files
__pycache__
_build
*.pyc

# Sphinx build-specific files
_build

# This file results from running `pip -e install .` in a local repository
*.egg-info

# Virtual environment-specific files
.env
.python-version
build*/
bundles
.venv

# MacOS-specific files
*.DS_Store
.eggs
dist
**/*.egg-info

# IDE-specific files
.idea
.vscode
*~
47 changes: 13 additions & 34 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,19 @@
# SPDX-License-Identifier: Unlicense

repos:
- repo: https://github.com/python/black
rev: 22.3.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: black
- repo: https://github.com/fsfe/reuse-tool
rev: v0.14.0
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.4
hooks:
- id: reuse
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
- id: ruff-format
- id: ruff
args: ["--fix"]
- repo: https://github.com/fsfe/reuse-tool
rev: v3.0.1
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pycqa/pylint
rev: v2.15.5
hooks:
- id: pylint
name: pylint (library code)
types: [python]
args:
- --disable=consider-using-f-string,duplicate-code
exclude: "^(docs/|examples/|tests/|setup.py$)"
- id: pylint
name: pylint (example code)
description: Run pylint rules on "examples/*.py" files
types: [python]
files: "^examples/"
args:
- --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code
- id: pylint
name: pylint (test code)
description: Run pylint rules on "tests/*.py" files
types: [python]
files: "^tests/"
args:
- --disable=missing-docstring,consider-using-f-string,duplicate-code
- id: reuse
22 changes: 7 additions & 15 deletions adafruit_pyportal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

"""

import os
import gc
import os
import time

try:
Expand All @@ -29,8 +29,9 @@
pass
import terminalio
from adafruit_portalbase import PortalBase
from adafruit_pyportal.network import Network, CONTENT_JSON, CONTENT_TEXT

from adafruit_pyportal.graphics import Graphics
from adafruit_pyportal.network import CONTENT_JSON, CONTENT_TEXT, Network
from adafruit_pyportal.peripherals import Peripherals

__version__ = "0.0.0-auto.0"
Expand Down Expand Up @@ -93,8 +94,7 @@ class PyPortal(PortalBase):

"""

# pylint: disable=too-many-instance-attributes, too-many-locals, too-many-branches, too-many-statements, unused-argument
def __init__(
def __init__( # noqa: PLR0912,PLR0913,PLR0915 Too many branches,Too many arguments in function definition,Too many statements
self,
*,
url=None,
Expand Down Expand Up @@ -127,9 +127,8 @@ def __init__(
debug=False,
display=None,
touchscreen=None,
secrets=None
secrets=None,
):

if external_spi: # If SPI Object Passed
spi = external_spi
else: # Else: Make ESP32 connection
Expand Down Expand Up @@ -196,10 +195,8 @@ def __init__(

self.image_converter_url = self.network.image_converter_url
self.wget = self.network.wget
# pylint: disable=invalid-name
self.show_QR = self.graphics.qrcode
self.hide_QR = self.graphics.hide_QR
# pylint: enable=invalid-name
self.resize_image = self.graphics.resize_image

if hasattr(self.peripherals, "touchscreen"):
Expand Down Expand Up @@ -239,9 +236,7 @@ def __init__(
self.set_caption(caption_text, caption_position, caption_color)

if text_font:
if text_position is not None and isinstance(
text_position[0], (list, tuple)
):
if text_position is not None and isinstance(text_position[0], (list, tuple)):
num = len(text_position)
if not text_wrap:
text_wrap = [0] * num
Expand Down Expand Up @@ -274,18 +269,15 @@ def __init__(
self._text = None

gc.collect()
# pylint: enable=unused-argument

def set_caption(self, caption_text, caption_position, caption_color):
# pylint: disable=line-too-long
"""A caption. Requires setting ``caption_font`` in init!

:param caption_text: The text of the caption.
:param caption_position: The position of the caption text.
:param caption_color: The color of your caption text. Must be a hex value, e.g.
``0x808000``.
"""
# pylint: enable=line-too-long
if self._debug:
print("Setting caption to", caption_text)

Expand All @@ -300,7 +292,7 @@ def set_caption(self, caption_text, caption_position, caption_color):
)
self.set_text(caption_text, index)

def fetch(self, refresh_url=None, timeout=10):
def fetch(self, refresh_url=None, timeout=10): # noqa: PLR0912 Too many branches
"""Fetch data from the url we initialized with, perfom any parsing,
and display text or graphics. This function does pretty much everything
Optionally update the URL
Expand Down
22 changes: 7 additions & 15 deletions adafruit_pyportal/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
# okay to run Generic Linux
DISPLAY_ARG_REQUIRED = True

import displayio
import adafruit_ili9341
from PIL import Image
import displayio
from adafruit_portalbase.graphics import GraphicsBase
from PIL import Image

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_Blinka_PyPortal.git"
Expand All @@ -45,16 +45,11 @@ class Graphics(GraphicsBase):

"""

# pylint: disable=too-few-public-methods
def __init__(self, *, default_bg=None, display=None, spi=None, debug=False):
if display is None:
if DISPLAY_ARG_REQUIRED:
raise RuntimeError(
"Display must be provided on platforms without board."
)
display_bus = displayio.FourWire(
spi, command=board.D25, chip_select=board.CE0
)
raise RuntimeError("Display must be provided on platforms without board.")
display_bus = displayio.FourWire(spi, command=board.D25, chip_select=board.CE0)
display = adafruit_ili9341.ILI9341(
display_bus, width=320, height=240, backlight_pin=board.D18
)
Expand All @@ -66,8 +61,7 @@ def __init__(self, *, default_bg=None, display=None, spi=None, debug=False):
# Tracks whether we've hidden the background when we showed the QR code.
self._qr_only = False

# pylint: disable=arguments-differ
def qrcode(self, qr_data, *, qr_size=1, x=0, y=0, hide_background=False):
def qrcode(self, qr_data, *, qr_size=1, x=0, y=0, hide_background=False): # noqa: PLR0913 Too many arguments in function definition
"""Display a QR code

:param qr_data: The data for the QR code.
Expand All @@ -86,13 +80,11 @@ def qrcode(self, qr_data, *, qr_size=1, x=0, y=0, hide_background=False):
self.display.show(self._qr_group)
self._qr_only = hide_background

# pylint: enable=arguments-differ

def hide_QR(self): # pylint: disable=invalid-name
def hide_QR(self):
"""Clear any QR codes that are currently on the screen"""

if self._qr_only:
self.display.show(self.splash)
self.display.root_group = self.root_group
else:
try:
self._qr_group.pop()
Expand Down
Loading