Coverage for src/chrisjen/reports.py: 100%
13 statements
« prev ^ index » next coverage.py v7.17.0, created at 2026-11-14 09:29 +0000
« prev ^ index » next coverage.py v7.17.0, created at 2026-11-14 09:29 +0000
1"""Subclasses of Report.
3Contents:
4 Summary: a short text summary of a project.
6"""
8from __future__ import annotations
10import dataclasses
11from typing import TYPE_CHECKING
13from . import base, utilities
15if TYPE_CHECKING:
16 from . import interface
19@dataclasses.dataclass
20class Summary(base.Report):
21 """A short text summary of a project.
23 Args:
24 contents: the text of the most recent summary. Defaults to `None`.
26 """
28 def generate(self, project: interface.Project) -> str:
29 """Generates the summary and stores it in `contents`.
31 Args:
32 project: the project to summarize.
34 Returns:
35 The text of the summary.
37 """
38 workflow = project.workflow
39 paths = [
40 utilities.label_path(path)
41 for path in (workflow.walk() if workflow is not None else [])]
42 lines = [
43 f'project: {project.name}',
44 f'id: {project.id}',
45 f'paths: {"; ".join(paths) or "none"}',
46 f'result: {project.result!r}',
47 ]
48 text = '\n'.join(lines)
49 self.contents = text
50 return text