made image generation exception safe

This commit is contained in:
weckyy702
2020-12-27 16:01:03 +01:00
parent 317387e24d
commit 688c4ad0ac
3 changed files with 22 additions and 10 deletions

View File

@@ -0,0 +1,13 @@
import draw.code_to_image as cti
class NSD_writer(object):
def __init__(self, filepath: str, x_sz: int, y_sz: int) -> None:
self.filepath = filepath
self.x_sz = x_sz
self.y_sz = y_sz
def __enter__(self):
cti.NSD_init(self.x_sz, self.y_sz)
def __exit__(self, _, __, ___):
cti.NSD_save(self.filepath)