Let the project name and the manufacturer be supplied on the command line

Neither is recorded in the artifacts: the metadata's repository_name is
empty and nothing names a manufacturer. --project wins over the metadata.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
alexanderandClaude Opus 5.5 committed 2026-09-24 20:41:56 +02:00
1 parent 5959d9364b
commit dc8ed38d8c
4 files changed
+69 -15

No files matched your search

+33 -4
View File
@@ -32,11 +32,15 @@ class GenerateProperties(BaseModel):
scan_id: The scan to report on. The store is keyed by it.
path: Where to write the PDF. A directory is written into under the name
the renderer chose; leaving it out writes into ``reports/``.
project: The name of the scanned project, as the report states it.
manufacturer: Who makes the scanned product, as the report states it.
storage_config: The store the scan's artifacts are read from.
"""
scan_id: UUID = Field(description="The scan the report should be generated for.")
path: Path | None = Field(default=None, description="Where to write the PDF report.")
project: str | None = Field(default=None, description="The name of the scanned project.")
manufacturer: str | None = Field(default=None, description="The manufacturer of the scanned product.")
storage_config: StorageConfiguration
@@ -48,6 +52,8 @@ class FolderProperties(BaseModel):
scan_id: The scan to report under. Read out of the artifacts when not
given -- an export names its own run.
path: Where to write the PDF, as above.
project: The name of the scanned project, as above.
manufacturer: Who makes the scanned product, as above.
"""
artifacts: Path = Field(description="Folder of exported artifacts to build the report from.")
@@ -55,6 +61,8 @@ class FolderProperties(BaseModel):
default=None, description="The scan to report under. Read from the artifacts when omitted."
)
path: Path | None = Field(default=None, description="Where to write the PDF report.")
project: str | None = Field(default=None, description="The name of the scanned project.")
manufacturer: str | None = Field(default=None, description="The manufacturer of the scanned product.")
class GeneratedReport(BaseModel):
@@ -89,7 +97,12 @@ def generate(properties: GenerateProperties) -> GeneratedReport:
PipelineError: The scan cannot be read, is missing an input the report
needs, or the destination cannot be written.
"""
return _report(collect(properties.storage_config, properties.scan_id), properties.path)
return _report(
collect(properties.storage_config, properties.scan_id),
properties.path,
project=properties.project,
manufacturer=properties.manufacturer,
)
def from_folder(properties: FolderProperties) -> GeneratedReport:
@@ -107,10 +120,23 @@ def from_folder(properties: FolderProperties) -> GeneratedReport:
PipelineError: The folder cannot be read, names no scan, is missing an
input the report needs, or the destination cannot be written.
"""
return _report(collect_from_directory(properties.artifacts, properties.scan_id), properties.path, write_metrics=True)
return _report(
collect_from_directory(properties.artifacts, properties.scan_id),
properties.path,
project=properties.project,
manufacturer=properties.manufacturer,
write_metrics=True,
)
def _report(sources: ReportSources, path: Path | None, *, write_metrics: bool = False) -> GeneratedReport:
def _report(
sources: ReportSources,
path: Path | None,
*,
project: str | None = None,
manufacturer: str | None = None,
write_metrics: bool = False,
) -> GeneratedReport:
"""Render the collected artifacts and write the result.
Everything after the artifacts are in hand, which is the same whichever of the two collected
@@ -119,6 +145,9 @@ def _report(sources: ReportSources, path: Path | None, *, write_metrics: bool =
Args:
sources: The scan and its files.
path: Where the caller asked for the PDF, if anywhere in particular.
project: The project name the caller supplied, if any.
manufacturer: The manufacturer the caller supplied, if any.
write_metrics: Whether to write ``metrics.json`` beside the PDF.
Returns:
The report that was written.
@@ -127,7 +156,7 @@ def _report(sources: ReportSources, path: Path | None, *, write_metrics: bool =
PipelineError: The report cannot be built or the destination not written.
"""
metrics = build_metrics(sources)
name, content = render(sources, metrics)
name, content = render(sources, metrics, project=project, manufacturer=manufacturer)
destination = _destination(path, name)
try: