File size: 462 Bytes
2603a5d
 
 
 
 
 
 
 
 
 
 
 
 
5b1b1c7
2603a5d
 
 
1df376e
2603a5d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import string
import typing


def render_template(
    template_filename: str,
    context: dict[str, typing.Any]
) -> str:
    with open(template_filename) as f:
        template = string.Template(f.read())
    return template.safe_substitute(context)


def render_track(tracks: list[list[int]]) -> str:
    return '\n'.join([
        '[',
        *[f'  [{", ".join(map(str, track))}],' for track in tracks],
        f'];  // lines count: {len(tracks)}'
    ])