o
    !wÖid  ã                   @   sJ   d Z ddlZddlmZ ddlmZ dd„ Ze d¡G d	d
„ d
e	ƒƒZ
dS )a©  
JPype Beans Module
------------------

This customizer finds all occurences of methods with get or set and converts
them into Python properties. This behavior is sometimes useful in programming
with JPype with interactive shells, but also leads to a lot of confusion.
Is this class exposing a variable or is this a property added JPype.  

As an unnecessary behavior that violates both the Python principle
*"There should be one-- and preferably only one --obvious way to do it."* and
the C++ principle *"You only pay for what you use"*.  This misfeature
was removed from the distribution as a default. However, given that it is
useful to have methods appear as properties, it was moved to a
an optional module.

To use beans as properties:

.. code-block:: python

  import jpype.beans

The beans property modification is a global behavior and applies retroactively
to all classes currently loaded.  Once started it can not be undone.
é    Né   )Ú_jcustomizer)Úpysafec              	   C   sæ   i }|   ¡ D ]j\}}t|tjƒrt|ƒdkrq|dkrq| ¡ rF|d  ¡ |dd…  }z
|| }||d< W q tyE   |dg||< Y qw | ¡ rp|d  ¡ |dd…  }z
|| }||d< W q tyo   d|g||< Y qw q|S )a°  Extract pairs of corresponding property access methods
    (getter and setter) from a Java class's members (attributes).

    If a public method with a property's name exists no pair for
    that property will be extracted.

    Returns a dictionary with the property name as key and a tuple
    of (getter method, setter method) as value. A tuple element
    value might be `None` if only a getter or only a setter
    exists.
    é   ÚgetClassé   Nr   r   )	ÚitemsÚ
isinstanceÚ_jpypeÚ_JMethodÚlenÚ_isBeanAccessorÚlowerÚKeyErrorÚ_isBeanMutator)ÚmembersÚaccessor_pairsÚnameÚmemberÚproperty_nameÚpair© r   úH/home/ubuntu/sommelier/.venv/lib/python3.10/site-packages/jpype/beans.pyÚ_extract_accessor_pairs0   s0   ÿÿûr   zjava.lang.Objectc                   @   s   e Zd ZdZdd„ ZdS )Ú_BeansCustomizerz= Add properties for get/set Bean patterns found in classes.  c                 C   sR   t | jƒ}| ¡ D ]\}\}}t|ƒ}|d u s|| jv rq	|  |t||ƒ¡ q	d S )N)r   Ú__dict__r   Ú_pysafeÚ
_customizeÚproperty)Úselfr   Ú	attr_nameÚgetterÚsetterr   r   r   Ú__jclass_init__Y   s   
øz _BeansCustomizer.__jclass_init__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r#   r   r   r   r   r   U   s    r   )r'   r
   Ú r   Ú_pykeywordsr   r   r   ÚJImplementationForÚobjectr   r   r   r   r   Ú<module>   s   %