
    q'VeC                     n    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Z	d Z
d	 Zd
 Zd Zd ZdS )z2Provides utility functions for use by QtPy itself.    )wraps)TYPE_CHECKINGN)QAction)wrapperc                2     |di |}| |_         ||_         |S )zDCreate a __cause__-chained wrapper error for a missing optional dep. )	__cause__)
attr_errorimport_errorr   wrapper_kwargs
qtpy_errors        +lib/python3.11/site-packages/qtpy/_utils.py _wrap_missing_optional_dep_errorr      s/     **>**J'L'J    c                 ^    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_nameoptional_namesr
   s       r   getattr_missing_optional_depr       s`    ;+;;4;; J ~/
 
T"
 
 	
 r   c                    |s|s|                                  S t          |d         |           rJt          |          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kwargss      r   possibly_static_execr!   -   s      xxzz$q'3 1t99>>&>7<<>>!tAw|T!""X000038T$V$$$r   c                    |s|s|                                  S t          |d         |           rJt          |          dk    r|s|d                                          S  |d         j         |dd         i |S  | j         |i |S r   )exec_r   r   r   s      r   possibly_static_exec_r$   ;   s      yy{{$q'3 2t99>>&>7==??"tAw}d122h1&11139d%f%%%r   c                @   ddl m} ddlm}m} t          d t          |t          ||j        t          t          f|t          g          D                       rt          |          dk    r'|\  }} || |          }|                    |           not          |          dk    r)|\  }}}	 || ||	          }|                    |           n3t          |          dk    r|\  }}}	}
 || ||	|
|          }n	 || g|R  S |S t          d t          ||t          ||j        t          t          f|t          g          D                       rt          |          dk    r2|\  }}} || ||          }|                     ||                     nt          |          dk    r4|\  }}}}	 || |||	          }|                     ||                     n>t          |          d	k    r"|\  }}}}	}
 || |||	|
 ||                    }n	 || g|R  S |S  || g|R  S )
zIRe-order arguments of `addAction` to backport compatibility with Qt>=6.3.r   )QObject)QIconQKeySequencec              3   <   K   | ]\  }}t          ||          V  d S Nr   .0argts      r   	<genexpr>zadd_action.<locals>.<genexpr>T   sD        C 	3     r            c              3   <   K   | ]\  }}t          ||          V  d S r*   r+   r,   s      r   r0   zadd_action.<locals>.<genexpr>n   sD        C 	3     r      )qtpy.QtCorer&   
qtpy.QtGuir'   r(   allzipstrStandardKeyintbytesr   setShortcut)selfold_add_actionr   r&   r'   r(   textshortcutactionreceivermembericons               r   
add_actionrG   I   s   ######........   |7cB	
 
      t99>>!ND(#^D$//Fx((((YY!^^'+$D(H#^D$99Fx((((YY!^^/3,D(Hf#^D$&(KKFF!>$.....
  |7cB	
 	
     ! t99>>#' D$#^D$55F||H556666YY!^^-1*D$(#^D$h??F||H556666YY!^^592D$(F#^X&& FF ">$.....>$&&&&&r   c                 ^     t           t                      f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                  L    |v r|                               |<    | i |S r*   )pop)r   r    from_kwarg_namefuncto_kwarg_names     r   _from_kwarg_name_to_kwarg_name_zEstatic_method_kwargs_wrapper.<locals>._from_kwarg_name_to_kwarg_name_   s;     f$$$*JJ$?$?F=!tT$V$$$r   )staticmethodr   )rL   rK   rM   rN   s   ``` r   static_method_kwargs_wrapperrP      sL     
4[[% % % % % % [ \%
 +*r   )__doc__	functoolsr   typingr   qtpyqtpy.QtWidgetsr   QtModuleNotInstalledErrorr   r   r!   r$   rG   rP   r   r   r   <module>rW      s    9 8                    '&&&&&& *	    
 
 
% % %& & &G' G' G'T+ + + + +r   