pyragephoto: add 'with' support
This commit is contained in:
parent
c55b99e23f
commit
18325f7c05
1 changed files with 9 additions and 1 deletions
|
@ -79,7 +79,15 @@ class RagePhoto:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.__instance = libragephoto.ragephoto_open()
|
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):
|
def __del__(self):
|
||||||
|
if self.__instance is not None:
|
||||||
libragephoto.ragephoto_close(self.__instance)
|
libragephoto.ragephoto_close(self.__instance)
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
|
|
Loading…
Reference in a new issue