feat(v1.2.0): retry API, dernier commit, tri, coloration, export JSON
- client.py: _get_with_retry (max 2 retries, backoff lineaire), get_latest_commit - collector.py: champ last_commit_date dans RepoData - display.py: colonne "Dernier commit", _sort_repos (name/issues/release/activity), _colorize_milestone_due (rouge/jaune/vert selon echeance) - cli.py: options --sort/-s et --format/-f (table/json) - exporter.py: nouveau module, repos_to_dicts + export_json - 88 tests (35 nouveaux), ruff clean fixes #8, fixes #7, fixes #10, fixes #9, fixes #6 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
26
src/gitea_dashboard/exporter.py
Normal file
26
src/gitea_dashboard/exporter.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""Export des donnees du dashboard en formats structures."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from dataclasses import asdict
|
||||
|
||||
from gitea_dashboard.collector import RepoData
|
||||
|
||||
|
||||
def repos_to_dicts(repos: list[RepoData]) -> list[dict]:
|
||||
"""Convertit une liste de RepoData en liste de dicts serialisables.
|
||||
|
||||
Chaque dict contient toutes les donnees du RepoData,
|
||||
pret pour json.dumps().
|
||||
"""
|
||||
return [asdict(repo) for repo in repos]
|
||||
|
||||
|
||||
def export_json(repos: list[RepoData], indent: int = 2) -> str:
|
||||
"""Exporte les repos en JSON formate.
|
||||
|
||||
Returns:
|
||||
Chaine JSON indentee, prete pour stdout ou ecriture fichier.
|
||||
"""
|
||||
return json.dumps(repos_to_dicts(repos), indent=indent, ensure_ascii=False)
|
||||
Reference in New Issue
Block a user