Automathèque
Code de base pour automatheque.
Installation
mais il est peu probable que vous ayez besoin de l'installer, c'est avant tout une dépendance.
pip install automatheque
Dépendances
- voir
pyproject.toml
Install en mode dev
pip install -e .[dev,docs] ou monas install depuis la racine.
Usage : Utilitaire pour script
from automatheque.script import script # alias court de script_automatheque
@script(__doc__, __version__)
def main(_script):
print(_script.config)
if __name__ == '__main__':
main()
L'API a été promue de
automatheque.util.scriptversautomatheque.script(#41). L'ancien chemin reste importable (shim) mais émet unDeprecationWarning: migrez versfrom automatheque.script import script.
Le décorateur câble automatiquement, si le script les déclare dans son usage :
--dry-run (via _script.dry_run), la verbosité -v/-q (niveau de log), une
sortie propre sur Ctrl-C (code 130), et la durée d'exécution.
Sous-commandes (via commandopt)
On déclare des fonctions-commandes avec @commande([...]) (alias de
commandopt.commandopt) et on aiguille avec _script.execute_commande(). Les
options internes d'automatheque (--config, --dry-run, -v/-q) sont
exclues de la sélection, mais restent transmises à la commande.
"""Mon script
Usage:
mon_script.py (--ajouter | --supprimer) [--config=<f>] [-v]
"""
from automatheque.script import script, commande
@commande(["--ajouter"])
def ajouter(arguments):
...
@commande(["--supprimer"])
def supprimer(arguments):
...
@script(__doc__, __version__)
def main(_script):
return _script.execute_commande()
if __name__ == '__main__':
main()
Configuration du logging
Automathèque ne configure rien à l'import (une bibliothèque ne doit pas
toucher au logging global). C'est l'application qui configure : un script
décoré par @script_automatheque appelle configure_logging_defaut() (sortie
console) puis applique la section [log] de sa configuration.
Un script étant une application, sa configuration de log vise la racine :
logging.getLogger(__name__) dans le script et les loggers des dépendances
en héritent.
Forme simple (inline dans le .ini)
Dans le config.ini du script (~/.config/<mon_script>/config.ini) :
[log]
niveau = INFO
fichier = mon_script.log ; optionnel (sinon console)
format = %%(asctime)s [%%(levelname)s] %%(name)s: %%(message)s
; niveaux par logger (nom seul = niveau global) :
names = automatheque:WARNING, mon_script:DEBUG, requests:ERROR
Dans un
.ini, les%se doublent en%%(convention ConfigParser) ; un%non échappé lève une erreur explicite.
Un seul handler/destination est partagé ; names n'ajuste que des niveaux.
Forme complète (dictConfig externe)
Pour router des loggers vers des destinations différentes (erreurs du script dans un fichier, automatheque ailleurs…), pointer vers un dictConfig complet (JSON ou YAML, détecté au contenu) :
[log]
fichier_config = log.yaml
Voir l'exemple canonique log.yaml.dist.
Release files for automatheque 0.16.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| automatheque-0.16.0.tar.gz | 42.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| automatheque-0.16.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 84.4 kB
Release files / automatheque-0.16.0.tar.gz
| Download URL | automatheque-0.16.0.tar.gz |
|---|---|
| Size | 42.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a36e9b55d921fcae99a43a5cde80ba2d6cb263b9b9586d991f2ba7472b3c733b
|
|
BLAKE2b-256 checksum How to use checksums |
36c7eb5f6a6839b596cca70b070ac638e6d0cebfb12b2c44b2d7fa4f2370f702
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / automatheque-0.16.0-py3-none-any.whl
| Download URL | automatheque-0.16.0-py3-none-any.whl |
|---|---|
| Size | 42.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e0927ac2106548cd0dd76ceb3063f0cd11e59d43834ce91ec068729b711af1b
|
|
BLAKE2b-256 checksum How to use checksums |
b320f4f2770fce496639aa4936f48fd377cd9e6f51244c2da75e62a77315e5df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency log