pyragephoto: add 'with' support
This commit is contained in:
		
							parent
							
								
									c55b99e23f
								
							
						
					
					
						commit
						18325f7c05
					
				
					 1 changed files with 9 additions and 1 deletions
				
			
		| 
						 | 
					@ -79,8 +79,16 @@ class RagePhoto:
 | 
				
			||||||
  def __init__(self):
 | 
					  def __init__(self):
 | 
				
			||||||
    self.__instance = libragephoto.ragephoto_open()
 | 
					    self.__instance = libragephoto.ragephoto_open()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  def __del__(self):
 | 
					  def __enter__(self):
 | 
				
			||||||
 | 
					    return self
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def __exit__(self, type, value, traceback):
 | 
				
			||||||
    libragephoto.ragephoto_close(self.__instance)
 | 
					    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):
 | 
					  def clear(self):
 | 
				
			||||||
    libragephoto.ragephoto_clear(self.__instance)
 | 
					    libragephoto.ragephoto_clear(self.__instance)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue