o
    tfC                     @   sp   d Z ddlmZ ddlmZ ddlZerddlmZ ejdddZ	d	d
 Z
dd Zdd Zdd Zdd ZdS )z2Provides utility functions for use by QtPy itself.    )wraps)TYPE_CHECKINGN)QAction)wrapperc                K   s   |di |}| |_ ||_ |S )zDCreate a __cause__-chained wrapper error for a missing optional dep.N )	__cause__)
attr_errorimport_errorr   Zwrapper_kwargsZ
qtpy_errorr   r   T/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/qtpy/_utils.py _wrap_missing_optional_dep_error   s   r   c                 C   s4   t d|d| }| |v rt|fi ||  S |S )z5Wrap AttributeError in a special error if it matches.zmodule z has no attribute )AttributeErrorr   )namemodule_nameZoptional_namesr   r   r   r
   getattr_missing_optional_dep    s   r   c                 O   f   |s|s|   S t|d | r+t|dkr|s|d   S |d j |dd i |S | j |i |S zCCall `self.exec` when `self` is given or a static method otherwise.r      N)exec
isinstancelenclsargskwargsr   r   r
   possibly_static_exec-      r   c                 O   r   r   )exec_r   r   r   r   r   r
   possibly_static_exec_;   r   r   c             
   G   s  ddl m} ddlm}m} tdd t|t||jtt	f|t
gD rot|dkr9|\}}|| |}|| |S t|dkrQ|\}}}	|| ||	}|| |S t|dkrg|\}}}	}
|| ||	|
|}|S || g|R  S td	d t||t||jtt	f|t
gD rt|dkr|\}}}|| ||}||| |S t|dkr|\}}}}	|| |||	}||| |S t|d
kr|\}}}}	}
|| |||	|
||}|S || g|R  S || g|R  S )zIRe-order arguments of `addAction` to backport compatibility with Qt>=6.3.r   )QObject)QIconQKeySequencec                 s       | ]
\}}t ||V  qd S Nr   .0argtr   r   r
   	<genexpr>T   
    
zadd_action.<locals>.<genexpr>         c                 s   r!   r"   r#   r$   r   r   r
   r(   n   r)      )Zqtpy.QtCorer   Z
qtpy.QtGuir   r    allzipstrZStandardKeyintbytesr   ZsetShortcut)selfZold_add_actionr   r   r   r    textZshortcutactionZreceivermembericonr   r   r
   
add_actionI   sz   






r8   c                    s    t t fdd}|S )z
    Helper function to manage `from_kwarg_name` to `to_kwarg_name` kwargs name changes in static methods.

    Makes static methods accept the `from_kwarg_name` kwarg as `to_kwarg_name`.
    c                     s$    |v r|  |< | i |S r"   )pop)r   r   from_kwarg_namefuncto_kwarg_namer   r
   _from_kwarg_name_to_kwarg_name_   s   zEstatic_method_kwargs_wrapper.<locals>._from_kwarg_name_to_kwarg_name_)staticmethodr   )r<   r;   r=   r>   r   r:   r
   static_method_kwargs_wrapper   s   r@   )__doc__	functoolsr   typingr   ZqtpyZqtpy.QtWidgetsr   ZQtModuleNotInstalledErrorr   r   r   r   r8   r@   r   r   r   r
   <module>   s   J