o
    ß­j‰	  ã                   @  sh   d dl mZ d dlZd dlZd dlZd dlZd dlZdd„ Zdd„ Zdd„ Z	e 
¡ Ze ¡ d	d
„ ƒZdS )é    )ÚannotationsNc                   s   ‡ fdd„}|S )z/A decorator to set the docstring of a function.c                   s
   ˆ | _ | S ©N)Ú__doc__)Úf©Údoc© ú]/var/www/html/CropPilot/venv/lib/python3.10/site-packages/google/generativeai/string_utils.pyÚinner   s   zset_doc.<locals>.innerr   )r   r
   r   r   r	   Úset_doc   s   r   c                 C  s.   |   ¡ }dd„ |D ƒ}dd„ |D ƒ}d |¡S )Nc                 S  ó   g | ]}d |vr|‘qS )z
.. _oneof:r   ©Ú.0Úliner   r   r	   Ú
<listcomp>$   ó    zstrip_oneof.<locals>.<listcomp>c                 S  r   )z"This field is a member of `oneof`_r   r   r   r   r	   r   %   r   Ú
)Ú
splitlinesÚjoin)Ú	docstringÚlinesr   r   r	   Ústrip_oneof"   s   
r   c                 C  s   t | _t | _| S r   )Ú_prettyprintÚ__str__Ú__repr__)Úclsr   r   r	   Úprettyprint)   s   r   c                 C  s  g }t  | ¡D ]X}t t| |jƒ¡}d}| d¡dkrB| d¡r#d}n1| d¡r+d}n)tj	||tj
d�r?tj|d	|tj
d�}nd
}nt|jƒd }t |d| ¡ d¡}| |j› d|› �¡ qd |¡}| jj}t|ƒd }t |d| ¡ d¡}|› d|› d�S )aS  A dataclass prettyprint function you can use in __str__or __repr__.

    Note: You can't set `__str__ = pprint.pformat` because it causes a recursion error.

    Mostly identical to pprint but:

    * This will contract long lists and dicts (> 10lines) to [...] and {...}.
    * This will contract long object reprs to ClassName(...).
    z^(\w+)\(.*\)$r   é
   ú[z[...]Ú{z{...})Úflagsz\1(...)z...é   ú ú=z,
ú(ú))ÚdataclassesÚfieldsÚpprintÚpformatÚgetattrÚnameÚcountÚ
startswithÚreÚmatchÚDOTALLÚsubÚlenÚtextwrapÚindentÚlstripÚappendr   Ú	__class__Ú__name__)Úselfr'   r   ÚsÚclass_reÚwidthÚattrsr+   r   r   r	   r   2   s(   


r   )Ú
__future__r   r&   r(   r.   Úreprlibr3   r   r   r   ÚReprÚreprÚrecursive_reprr   r   r   r   r	   Ú<module>   s   
