pyragephoto: add 'with' support

This commit is contained in:
Syping 2024-03-25 13:43:10 +01:00
parent c55b99e23f
commit 18325f7c05

View file

@ -79,7 +79,15 @@ class RagePhoto:
def __init__(self):
self.__instance = libragephoto.ragephoto_open()
def __enter__(self):
return self
def __exit__(self, type, value, traceback):
libragephoto.ragephoto_close(self.__instance)
self.__instance = None
def __del__(self):
if self.__instance is not None:
libragephoto.ragephoto_close(self.__instance)
def clear(self):