MCPcopy
hub / github.com/cosmicpython/book / render_image

Function render_image

render-diagrams.py:69–79  ·  view source on GitHub ↗
(source, image_id)

Source from the content-addressed store, hash-verified

67
68
69def render_image(source, image_id):
70 source = _add_dots(source, image_id)
71 print(source)
72 target = Path(f'images/{image_id}.png')
73 if target.exists():
74 target.unlink()
75 tf = Path(tempfile.NamedTemporaryFile().name)
76 tf.write_text(source)
77 cmd = ['asciidoctor', '-r', 'asciidoctor-diagram', '-a', f'imagesoutdir={IMAGES_DIR}', str(tf)]
78 print(' '.join(cmd))
79 subprocess.run(cmd, check=True)
80
81
82if __name__ == '__main__':

Callers 1

render_imagesFunction · 0.85

Calls 1

_add_dotsFunction · 0.85

Tested by

no test coverage detected