o
    !wÖi5  ã                   @   s>   d dl mZ ddlZd dl mZ e d¡G dd„ deƒƒZdS )é   )Ú_jcustomizeré    N)Ú_jexceptionzjava.lang.AutoCloseablec                   @   s    e Zd ZdZdd„ Zdd„ ZdS )Ú_JCloseableaÉ   Customizer for ``java.lang.AutoCloseable`` and ``java.io.Closeable``

    This customizer adds support of the ``with`` operator to all Java
    classes that implement the Java ``AutoCloseable`` interface.

    Example:

    .. code-block:: python

        from java.nio.files import Files, Paths
        with Files.newInputStream(Paths.get("foo")) as fd:
          # operate on the input stream

        # Input stream closes at the end of the block.

    c                 C   s   | S )N© )Úselfr   r   úG/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/jpype/_jio.pyÚ	__enter__-   s   z_JCloseable.__enter__c              
   C   sP   t  ¡ }z|  ¡  W d S  tjy' } z|d d u r|‚W Y d }~d S d }~ww )Nr   )Ú_sysÚexc_infoÚcloser   Ú
JException)r   Úexception_typeÚexception_valueÚ	tracebackÚinfoÚjexr   r   r   Ú__exit__0   s   ÿ€þz_JCloseable.__exit__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r   r   r   r   r      s    r   )Ú r   Úsysr
   r   ÚJImplementationForÚobjectr   r   r   r   r   Ú<module>   s
   