Config strictement stricte partout (ruff, mypy --strict, bandit, vulture, import-linter, eslint, stylelint), aucune regle desactivee "pour ne pas casser le build" - l'existant a ete corrige pour la satisfaire plutot que l'inverse. Hooks pre-commit locaux (language: system) bloquants. - Typage mypy --strict propage a tout le moteur (db, screens, auth, core, ai, routes, puis publish/scripts/tests/app.py/build_css.py). - Securite : fuite de handle fichier Windows corrigee dans l'export SCORM (routes/publish/export_scorm.py), CSRF/RNG non-crypto/xAPI documentes (# nosec, # NOSONAR justifies), nouveau db.json_for_script() (echappe "</script>" dans le JSON embarque en <script>, 25 sites). - Architecture : imports circulaires/F811 nettoyes, contrats import-linter respectes, code mort retire (vulture). - Accessibilite : 69 champs de formulaire sans label correctement associe corriges (for/id ou aria-label) sur 11 templates. - ESLint/Stylelint : lot mecanique JS/CSS, regles ajustees puis appliquees (aucune desactivee sans verification individuelle). - Tests : isolation du compte admin partage (nettoyage ponctuel + fixture de teardown automatique en filet de securite), suite complete verte (591 tests Python, 241 tests JS). - SonarQube Community Build self-heberge (Docker + PostgreSQL) : rapport complet analyse point par point, faux positifs documentes. - .gitattributes ajoute (LF force) : core.autocrlf=true sur cette machine faisait echouer ESLint (linebreak-style) via un bug connu de git (checkout "en place" qui ignore l'eol force sur un fichier deja present sur disque - contourne en supprimant puis recreant chaque fichier suivi). djLint (H021, styles inline) volontairement saute pour ce commit - backlog assume, deja documente, traite dans un lot separe. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
68 lines
2.5 KiB
Python
68 lines
2.5 KiB
Python
import json
|
|
import os
|
|
from typing import Any
|
|
|
|
# Bibliothèque de sprites animaux CraftPix — RÉSERVÉE au rôle admin (voir
|
|
# routes/screens/screen_edit.py, routes/scenes/scene_edit_view.py, et les
|
|
# routes d'écriture screens/scene-objects "personnage"/"add"). Licence
|
|
# CraftPix : interdiction de rendre ces sprites utilisables par un compte
|
|
# "user" via l'application (voir le plan "Bibliothèque de sprites animaux
|
|
# CraftPix"). Générée une fois par scripts/generate_animal_sprite_manifest.py
|
|
# depuis assets/characters/animal_sprite/ (pack source, non versionné) vers
|
|
# static/characters/animals/<animal>/<NN>/<pose><i>.png, avec un manifest
|
|
# JSON décrivant le compte RÉEL de frames par pose/variante (variable selon
|
|
# les packs — pas de table figée comme _SEQUENCE_ANIMATIONS pour Kenney).
|
|
_MANIFEST_PATH = os.path.join(
|
|
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
|
|
"static",
|
|
"characters",
|
|
"animals",
|
|
"manifest.json",
|
|
)
|
|
|
|
|
|
def _load_manifest() -> dict[str, Any]:
|
|
try:
|
|
with open(_MANIFEST_PATH, encoding="utf-8") as f:
|
|
return dict(json.load(f))
|
|
except FileNotFoundError:
|
|
# Poste de dev sans les assets animaux copiés (script pas encore
|
|
# lancé), ou paquet exporté pour un jeu qui n'utilise aucun
|
|
# personnage animal (voir publish/build_scorm_package.py, copie
|
|
# sélective) : aucun personnage animal disponible, pas une erreur.
|
|
return {}
|
|
|
|
|
|
def _slug(animal: str, nn: str) -> str:
|
|
return f"animal-{animal}-{nn}"
|
|
|
|
|
|
def _label(family_label: str, nn: str) -> str:
|
|
n = int(nn)
|
|
return f"{family_label} (variante {n})" if n > 1 else f"{family_label} (de base)"
|
|
|
|
|
|
def _animations_for(animal: str, nn: str, poses: dict[str, int]) -> dict[str, list[str]]:
|
|
return {
|
|
pose: [f"/static/characters/animals/{animal}/{nn}/{pose}{i}.png" for i in range(count)]
|
|
for pose, count in poses.items()
|
|
}
|
|
|
|
|
|
def _build_library() -> dict[str, dict[str, Any]]:
|
|
manifest = _load_manifest()
|
|
library: dict[str, dict[str, Any]] = {}
|
|
for animal, pack in manifest.items():
|
|
family_label = pack["label"]
|
|
for nn, poses in pack["variants"].items():
|
|
library[_slug(animal, nn)] = {
|
|
"label": _label(family_label, nn),
|
|
"animations": _animations_for(animal, nn, poses),
|
|
"family": animal,
|
|
"family_label": family_label,
|
|
}
|
|
return library
|
|
|
|
|
|
ADMIN_SPRITE_LIBRARY = _build_library()
|