Coding rules¶
Here is a small user guide and rules applied to develop pibooth. They
will be updated as we go along.
Conventions
The PEP8 naming rules are applied, with a line length limit of 160
characters rather than 79 — that is what the continuous integration checks.
A few habits are shared by the whole code base. New code is expected to match its surroundings rather than modernise them in passing:
every module starts with the
# -*- coding: utf-8 -*-headerlogging goes through
from pibooth.utils import LOGGER, with lazy arguments —LOGGER.info("Loaded %s", name)and not a pre-formatted stringpaths use
import os.path as ospstrings are formatted with
"{}".format(...)
Capture / Picture / Image
In the code and the configuration file:
captureis used for variables related to a raw image from the camera.pictureis used for variables related to the final image which is a concatenation of capture(s) and text(s).imageshall be used for pictograms displayed in Pygame view or intermediate PIL/OpenCv objects.
Configuration options naming
Option relative to a specific state shall have an name starting with the state name.
Option relative to a timeout shall have an name ending with _delay`.
Plugins naming
The core plugins expose a name attribute of the form
pibooth-core:<something>. That name is what [GENERAL][plugins_disabled]
matches against.
Contributing a change
Keep a change focused. Do not turn a feature change into a repository-wide lint cleanup.
Say plainly when a change could not be verified on real hardware, rather than implying it was tested.