Skip to content

Pdf

sereto.pdf

render_finding_group_pdf(finding_group, target, report, settings, version, recipe=None)

Render the finding group to PDF format according to the recipe.

Prerequisite is having the finding group in TeX format.

Parameters:

Name Type Description Default
finding_group FindingGroup

Finding group with all the sub-findings.

required
target Target

Target's representation.

required
report Report

Report's representation.

required
settings Settings

Global settings.

required
version ReportVersion

The version of the report.

required
recipe str | None

Name which will be used to pick a recipe from Render configuration. If none is provided, the first recipe (index 0) is used.

None
Source code in sereto/pdf.py
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
@validate_call
def render_finding_group_pdf(
    finding_group: FindingGroup,
    target: Target,
    report: Report,
    settings: Settings,
    version: ReportVersion,
    recipe: str | None = None,
) -> None:
    """Render the finding group to PDF format according to the recipe.

    Prerequisite is having the finding group in TeX format.

    Args:
        finding_group: Finding group with all the sub-findings.
        target: Target's representation.
        report: Report's representation.
        settings: Global settings.
        version: The version of the report.
        recipe: Name which will be used to pick a recipe from Render configuration. If none is provided, the first
            recipe (index 0) is used.
    """
    report_path = Report.get_path(dir_subtree=settings.reports_path)
    finding_group_tex_path = report_path / f"{target.uname}_{finding_group.uname}.tex"
    replacements = {"%FINDINGS_DIR%": str(report_path / target.uname / "findings")}

    if recipe is None:
        render_recipe = settings.render.finding_recipes[0]
    else:
        if len(res := [r for r in settings.render.target_recipes if r.name == recipe]) != 1:
            raise SeretoValueError(f"no finding recipe found with name {recipe!r}")
        render_recipe = res[0]

    _render_pdf(
        tex_path=finding_group_tex_path, render_recipe=render_recipe, settings=settings, replacements=replacements
    )

render_report_pdf(report, settings, version, recipe=None)

Render the report to PDF format according to the recipe.

Prerequisite is having the report in TeX format.

Parameters:

Name Type Description Default
report Report

Report's representation.

required
settings Settings

Global settings.

required
version ReportVersion

The version of the report.

required
recipe str | None

Name which will be used to pick a recipe from Render configuration. If none is provided, the first recipe (index 0) is used.

None
Source code in sereto/pdf.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
@validate_call
def render_report_pdf(report: Report, settings: Settings, version: ReportVersion, recipe: str | None = None) -> None:
    """Render the report to PDF format according to the recipe.

    Prerequisite is having the report in TeX format.

    Args:
        report: Report's representation.
        settings: Global settings.
        version: The version of the report.
        recipe: Name which will be used to pick a recipe from Render configuration. If none is provided, the first
            recipe (index 0) is used.
    """
    report_path = Report.get_path(dir_subtree=settings.reports_path)
    report_tex_path = report_path / f"report{version.path_suffix}.tex"

    if recipe is None:
        render_recipe = settings.render.report_recipes[0]
    else:
        if len(res := [r for r in settings.render.report_recipes if r.name == recipe]) != 1:
            raise SeretoValueError(f"no report recipe found with name {recipe!r}")
        render_recipe = res[0]

    _render_pdf(tex_path=report_tex_path, render_recipe=render_recipe, settings=settings)

render_sow_pdf(report, settings, version, recipe=None)

Render the SoW to PDF format according to the recipe.

Prerequisite is having the SoW in TeX format.

Parameters:

Name Type Description Default
report Report

Report's representation.

required
settings Settings

Global settings.

required
version ReportVersion

The version of the report.

required
recipe str | None

Name which will be used to pick a recipe from Render configuration. If none is provided, the first recipe (index 0) is used.

None
Source code in sereto/pdf.py
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
@validate_call
def render_sow_pdf(report: Report, settings: Settings, version: ReportVersion, recipe: str | None = None) -> None:
    """Render the SoW to PDF format according to the recipe.

    Prerequisite is having the SoW in TeX format.

    Args:
        report: Report's representation.
        settings: Global settings.
        version: The version of the report.
        recipe: Name which will be used to pick a recipe from Render configuration. If none is provided, the first
            recipe (index 0) is used.
    """
    report_path = Report.get_path(dir_subtree=settings.reports_path)
    sow_tex_path = report_path / f"sow{version.path_suffix}.tex"

    if recipe is None:
        render_recipe = settings.render.sow_recipes[0]
    else:
        if len(res := [r for r in settings.render.sow_recipes if r.name == recipe]) != 1:
            raise SeretoValueError(f"no SoW recipe found with name {recipe!r}")
        render_recipe = res[0]

    _render_pdf(tex_path=sow_tex_path, render_recipe=render_recipe, settings=settings)

render_target_pdf(target, report, settings, version, recipe=None)

Render the target to PDF format according to the recipe.

Prerequisite is having the target in TeX format.

Parameters:

Name Type Description Default
target Target

Target's representation.

required
report Report

Report's representation.

required
settings Settings

Global settings.

required
version ReportVersion

The version of the report.

required
recipe str | None

Name which will be used to pick a recipe from Render configuration. If none is provided, the first recipe (index 0) is used.

None
Source code in sereto/pdf.py
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
@validate_call
def render_target_pdf(
    target: Target, report: Report, settings: Settings, version: ReportVersion, recipe: str | None = None
) -> None:
    """Render the target to PDF format according to the recipe.

    Prerequisite is having the target in TeX format.

    Args:
        target: Target's representation.
        report: Report's representation.
        settings: Global settings.
        version: The version of the report.
        recipe: Name which will be used to pick a recipe from Render configuration. If none is provided, the first
            recipe (index 0) is used.
    """
    report_path = Report.get_path(dir_subtree=settings.reports_path)
    target_tex_path = report_path / f"{target.uname}.tex"
    replacements = {"%TARGET_DIR%": str(report_path / target.uname)}

    if recipe is None:
        render_recipe = settings.render.target_recipes[0]
    else:
        if len(res := [r for r in settings.render.target_recipes if r.name == recipe]) != 1:
            raise SeretoValueError(f"no target recipe found with name {recipe!r}")
        render_recipe = res[0]

    _render_pdf(tex_path=target_tex_path, render_recipe=render_recipe, settings=settings, replacements=replacements)