Skip to content

Build

sereto.build

build_subfinding_to_tex(project, target, sub_finding, version, converter=None)

Process one finding into TeX format and write it to the ".build" directory.

Source code in sereto/build.py
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
@validate_call
def build_subfinding_to_tex(
    project: Project,
    target: Target,
    sub_finding: SubFinding,
    version: ProjectVersion,
    converter: str | None = None,
) -> None:
    """Process one finding into TeX format and write it to the ".build" directory."""
    # Initialize the build directory
    init_build_dir(project_path=project.path, target=target)

    # Process the finding
    content = render_subfinding_to_tex(
        sub_finding=sub_finding,
        version=version,
        templates=project.settings.templates_path,
        render=project.settings.render,
        converter=converter,
    )

    # Write the finding to the ".build" directory; do not overwrite the same content (preserve timestamps)
    write_if_different(
        file=project.path / ".build" / target.uname / f"{sub_finding.path.name.removesuffix('.md.j2')}.tex",
        content=content,
    )

ensure_finding_group_layout(project_path, templates, target, finding_group, version)

Ensures that a template exists for the specified finding group.

Does not overwrite existing template.

Source code in sereto/build.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
@validate_call
def ensure_finding_group_layout(
    project_path: DirectoryPath,
    templates: DirectoryPath,
    target: Target,
    finding_group: FindingGroup,
    version: ProjectVersion,
) -> None:
    """Ensures that a template exists for the specified finding group.

    Does not overwrite existing template.
    """
    # Make sure that "layouts/generated" directory exists
    if not (layouts_generated := project_path / "layouts/generated").is_dir():
        layouts_generated.mkdir(parents=True)

    # Create template in "layouts/generated" directory
    template_dst = layouts_generated / f"{target.uname}_{finding_group.uname}.tex.j2"
    if not template_dst.is_file():  # do not overwrite existing templates
        template_src = templates / "categories" / target.data.category / "finding_group.tex.j2"
        copy2(template_src, template_dst, follow_symlinks=False)

ensure_target_layout(project_path, templates, target, version)

Ensures that a template exists for the specified target.

Does not overwrite existing template.

Source code in sereto/build.py
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
@validate_call
def ensure_target_layout(
    project_path: DirectoryPath, templates: DirectoryPath, target: Target, version: ProjectVersion
) -> None:
    """Ensures that a template exists for the specified target.

    Does not overwrite existing template.
    """
    # Make sure that "layouts/generated" directory exists
    if not (layouts_generated := project_path / "layouts/generated").is_dir():
        layouts_generated.mkdir(parents=True)

    # Create template in "layouts/generated" directory
    template_dst = layouts_generated / f"{target.uname}.tex.j2"
    if not template_dst.is_file():  # do not overwrite existing templates
        template_src = templates / "categories" / target.data.category / "target.tex.j2"
        copy2(template_src, template_dst, follow_symlinks=False)