26 lines
921 B
Python
26 lines
921 B
Python
from typing import List
|
|
from .base import Formatter
|
|
from ..types import ReportRow
|
|
|
|
|
|
class MarkdownFormatter(Formatter):
|
|
"""Форматтер для экспорта в Markdown."""
|
|
|
|
def format(self, rows: List[ReportRow]) -> str:
|
|
lines = [
|
|
"| Проект | Версия | Задача | Статус | Затрачено |",
|
|
"|--------|--------|--------|--------|-----------|"
|
|
]
|
|
for r in rows:
|
|
task_cell = f"{r['issue_id']}. {r['subject']}"
|
|
lines.append(
|
|
f"| {r['display_project']} | {r['display_version']} "
|
|
f"| {task_cell} | {r['status_ru']} | {r['time_text']} |"
|
|
)
|
|
return "\n".join(lines)
|
|
|
|
def save(self, rows: List[ReportRow], output_path: str) -> None:
|
|
content = self.format(rows)
|
|
with open(output_path, "w", encoding="utf-8") as f:
|
|
f.write(content)
|