
    T`2                        d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dl	m
Z
mZ d dlmZmZ d dlmZ  eee          Zi Z G d dej                  Z G d	 d
e          Zd Zd ZeZ	 d Zd Z e            i i edfdZddZd ZdS )    N)
get_loader)PyGIDeprecationWarning)CallableInfopygobject_new_full)	TYPE_NONETYPE_INVALID)extend_pathc                   4     e Zd ZdZ fdZd Zd Zd Z xZS )OverridesProxyModulez7Wraps a introspection module and contains all overridesc                 p    t          t          |                               |j                   || _        d S N)superr   __init____name___introspection_module)selfintrospection_module	__class__s     7/usr/lib/python3/dist-packages/gi/overrides/__init__.pyr   zOverridesProxyModule.__init__   s:    "D))22 )	+ 	+ 	+%9"""    c                 ,    t          | j        |          S r   )getattrr   )r   names     r   __getattr__z OverridesProxyModule.__getattr__   s    t14888r   c                    t          t          | j                            }|                    | j                                                   |                    t          | j                             t          |          S r   )setdirr   update__dict__keysr   sorted)r   results     r   __dir__zOverridesProxyModule.__dir__"   sb    S(())dm((**+++c$455666f~~r   c                 B    dt          |           j        d| j        dS )N< >)typer   r   )r   s    r   __repr__zOverridesProxyModule.__repr__(   s'      JJ///1K1K1KLLr   )	r   
__module____qualname____doc__r   r   r#   r)   __classcell__)r   s   @r   r   r      sr        AA: : : : :
9 9 9  M M M M M M Mr   r   c                   *    e Zd ZdZd Zd Zd Zd ZdS )_DeprecatedAttributezA deprecation descriptor for OverridesProxyModule subclasses.

    Emits a PyGIDeprecationWarning on every access and tries to act as a
    normal instance attribute (can be replaced and deleted).
    c                 \    || _         || _        t          |d|d|d          | _        d S )N. is deprecated; use  instead)_attr_valuer   _warning)r   	namespaceattrvaluereplacements        r   r   z_DeprecatedAttribute.__init__3   s=    
.		444./ /r   c                 r    |t          | j                  t          j        | j        d           | j        S )N   
stacklevel)AttributeErrorr4   warningswarnr6   r5   )r   instanceowners      r   __get__z_DeprecatedAttribute.__get__:   s7     ,,,dm2222{r   c                 p    | j         }t          t          |          |           t          |||           d S r   )r4   delattrr(   setattr)r   rB   r9   r8   s       r   __set__z_DeprecatedAttribute.__set__@   s7    zX%%%$&&&&&r   c                 J    t          t          |          | j                   d S r   )rF   r(   r4   )r   rB   s     r   
__delete__z_DeprecatedAttribute.__delete__F   s     X
+++++r   N)r   r*   r+   r,   r   rD   rH   rJ    r   r   r/   r/   ,   sZ         / / /  ' ' ', , , , ,r   r/   c                 n   | j                             dd          d         }d|z   }|t          j        v }t          j                            |          }t          |dz   t          fi           } ||           }|t          j        |<   ddlm} t          |d          sJ |||<   	 d	|z   }	 t          |          }	n# t          $ r d
}	Y nw xY w|	$| ||= t          j        |= |r|t          j        |<   S S t          j        |          }
||= t          j        |= |r|t          j        |<   n&# ||= t          j        |= |r|t          j        |<   w xY w||_        g }t          |
d          r|
j        }|D ]<}	 t          |
|          }n# t          t           f$ r Y 'w xY wt#          |||           =t$                              |g           D ]j\  }}	 t          ||          }n # t          $ r t)          d|z            w xY wt+          ||           t-          ||||          }t#          |||           k|S )zLoads overrides for an introspection module.

    Either returns the same module again in case there are no overrides or a
    proxy module including overrides. Doesn't cache the result.
    r1      gi.repository.ProxyModuler<   )modulesr   zgi.overrides.N__all__z1%s was set deprecated but wasn't added to __all__)r   rsplitsysrQ   getr(   r   importerhasattrr   r?   	importlibimport_module_overrides_modulerR   r   	TypeErrorrG   _deprecated_attrspopAssertionErrorrF   r/   )r   r7   
module_keyhas_old
old_module
proxy_typeproxyrQ   override_package_nameoverride_loaderoverride_modoverride_allvaritemr8   r:   r9   deprecated_attrs                     r   load_overridesrk   K   s    %-44S!<<R@I!I-J CK'G,,J i-/2F1I2NNJJ+,,E#CK
 #"""""5122222GI1 /) ;	#()>??OO 	# 	# 	#"OOO	#
 "'
 IK
# 	1&0CK
##	1 !./DEE IK
# 	1&0CK
# IK
# 	1&0CK
#0000 $EL|Y'' ,#+ " "	<--DD	* 	 	 	H	 	sD!!!! /229bAA 	3 	3k	LE4((EE 	L 	L 	L CdJL L L	L 	t.tUK1 1
D/2222LsT   &D* ,B< ;D* <CD* 
CD* 4D* *#E5FFFG!!G>c                    t          | t                    r?| }|j                            dd          d         }t          j        d|z            fd}|S t          | t          j                  rt          d| z            	 t          | d          }n%# t          $ r t          d| j        z            w xY w| j                            d	          st          d
| d| j        d          |                                }|t          k    sJ |t           k    r| |_        | j                            dd          d         }t          j        d|z            t%          | j        |            | S )a  Decorator for registering an override.

    Other than objects added to __all__, these can get referenced in the same
    override module via the gi.repository module (get_parent_for_object() does
    for example), so they have to be added to the module immediately.
    r1   rM   rN   rO   c                 4    t          | j        |            | S r   )rG   r   )funcmodules    r   wrapperzoverride.<locals>.wrapper   s    FDM4000Kr   z"func must be a gi function, got %s__info__zKCan not override a type %s, which is not in a gobject introspection typelibzgi.overrideszNYou have tried override outside of the overrides module. This is not allowed (, ))
isinstancer   r*   rS   rT   rQ   typesFunctionTyper[   r   r?   r   
startswithKeyError
get_g_typer   r   pytyperG   )type_rn   r7   rp   infog_typero   s         @r   overrider~      s    %&& "O**32226	-	9:	 	 	 	 	 	E5-	.	. <uDEEE	:5*--DD 	: 	: 	:(*/.9: : :	:
 **>:: 	L(27%%9I9I9IKL L L """"""\!!!FM$++C33B7	-	9:...s   B "B6c                 J     t          j                    fd            }|S )z7Decorator for marking methods and classes as deprecatedc                  b    t          j        j        ddt          d            | i |S )Nr2   r3   r<   r=   )r@   rA   r   r   )argskwargsfnr:   s     r   wrappedzdeprecated.<locals>.wrapped   sG    BKKKU,	< 	< 	< 	<r4"6"""r   	functoolswraps)r   r:   r   s   `` r   
deprecatedr      s>    _R# # # # # # Nr   c                 f    t                               | g                               ||f           dS )a:  Marks a module level attribute as deprecated. Accessing it will emit
    a PyGIDeprecationWarning warning.

    e.g. for ``deprecated_attr("GObject", "STATUS_FOO", "GLib.Status.FOO")``
    accessing GObject.STATUS_FOO will emit:

        "GObject.STATUS_FOO is deprecated; use GLib.Status.FOO instead"

    :param str namespace:
        The namespace of the override this is called in.
    :param str namespace:
        The attribute name (which gets added to __all__).
    :param str replacement:
        The replacement text which will be included in the warning.
    N)r\   
setdefaultappend)r7   r8   r:   s      r   rj   rj      s3    "   B//66k7JKKKKKr   r<   c                 *      fd}|S )a  Wrapper for deprecating GObject based __init__ methods which specify
    defaults already available or non-standard defaults.

    :param callable super_init_func:
        Initializer to wrap.
    :param list arg_names:
        Ordered argument name list.
    :param list ignore:
        List of argument names to ignore when calling the wrapped function.
        This is useful for function which take a non-standard keyword that is munged elsewhere.
    :param dict deprecated_aliases:
        Dictionary mapping a keyword alias to the actual g_object_newv keyword.
    :param dict deprecated_defaults:
        Dictionary of non-standard defaults that will be used when the
        keyword is not explicitly passed.
    :param Exception category:
        Exception category of the error.
    :param int stacklevel:
        Stack level for the deprecation passed on to warnings.warn
    :returns: Wrapped version of ``super_init_func`` which gives a deprecation
        warning when non-keyword args or aliases are used.
    :rtype: callable
    c           
         |r`t          j        dd                    	dt          |                             z  
           t	          t          	|                    }ni }|                    |           g }                                D ]6\  }}||v r-|                    |          ||<   |	                    |           7|rjt          j        dd                    fdt          |          D                       dd                    t          |                    d
           g }                                D ])\  }}||vr |         ||<   |	                    |           *|rFt          j        d	d                    fd
t          |          D                       z  
           D ]}||v r|                    |            | fi |S )zInitializer for a GObject based classes with support for property
        sets through the use of explicit keyword arguments.
        zUsing positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "%s" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecationsrr   Nr=   zThe keyword(s) "c              3   (   K   | ]}|         V  d S r   rK   ).0kdeprecated_aliasess     r   	<genexpr>z4deprecated_init.<locals>.new_init.<locals>.<genexpr>(  s)      $Y$Yq%7%:$Y$Y$Y$Y$Y$Yr   z$" have been deprecated in favor of "zM" respectively. See: https://wiki.gnome.org/PyGObject/InitializerDeprecationszInitializer is relying on deprecated non-standard defaults. Please update to explicitly use: %s See: https://wiki.gnome.org/PyGObject/InitializerDeprecationsc              3   2   K   | ]}|d |         V  dS )=NrK   )r   r   deprecated_defaultss     r   r   z4deprecated_init.<locals>.new_init.<locals>.<genexpr>7  s5      #i#iaqqq2Ea2H2H$I#i#i#i#i#i#ir   )r@   rA   joinlendictzipr   itemsr]   r   r!   )r   r   r   
new_kwargsaliases_usedkeyaliasdefaults_usedr9   	arg_namescategoryr   r   ignorer>   super_init_funcs            r   new_initz!deprecated_init.<locals>.new_init  sd   
  	M Z ))Ijs4yyj$9::; #z	; ; ; ;
 c)T2233JJJ&!!! ,2244 	) 	)JC
""",.."7"7
3##C((( 	;MM99$Y$Y$Y$YF<DXDX$Y$Y$YYYYY99VL%9%9::::< #z	; ; ; ; -3355 	* 	*JC*$$"5c":
3$$S))) 	;M Z ))#i#i#i#iSYZgShSh#i#i#iiij #z	; ; ; ;  	$ 	$Cj  s###t22z222r   rK   )r   r   r   r   r   r   r>   r   s   ``````` r   deprecated_initr      sH    <13 13 13 13 13 13 13 13 13 13 13f Or   c                 R     t          j                    fd            }|S )a  Translate method's return value for stripping off success flag.

    There are a lot of methods which return a "success" boolean and have
    several out arguments. Translate such a method to return the out arguments
    on success and None on failure.
    c                       | i |}|d         r%t          |          dk    r|d         S |dd          S r pd          S )Nr   r<   rM   zcall failed)r   )r   r   retexc_strexc_typefail_retmethods      r   r   z%strip_boolean_result.<locals>.wrappedK  sj    fd%f%%q6 	3xx1}}1v122w 9hw7-888Or   r   )r   r   r   r   r   s   ```` r   strip_boolean_resultr   D  sL     _V
 
 
 
 
 
 
 
 Nr   c                       fd}|S )Nc                 X    t          | d          } t          |d          } | |g|R  S )NF)r   )ab	user_datarn   s      r   wrapz'wrap_list_store_sort_func.<locals>.wrap\  s;    q%((q%((tAq%9%%%%r   rK   )rn   r   s   ` r   wrap_list_store_sort_funcr   Z  s#    & & & & &
 Kr   )NNN) r   ru   r@   rX   rT   pkgutilr   gir   gi._gir   r   gi._constantsr   r   r	   __path__r   r\   
ModuleTyper   objectr/   rk   r~   overridefuncr   rj   tupler   r   r   rK   r   r   <module>r      s             



       % % % % % % 3 3 3 3 3 3 3 3       
       ;x**  M M M M M5+ M M M*, , , , ,6 , , ,>S S Sl* * *Z    L L L( 8=uww')r3 Q Q Q Qh   ,    r   