ó
§Zc           @   s>  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	 d  d l
 m Z m Z d  d l m Z e e e ƒ Z i  Z d „  Z d e  j f d	 „  ƒ  YZ d
 e f d „  ƒ  YZ d „  Z d e f d „  ƒ  YZ d „  Z d „  Z d „  Z e ƒ  i  i  e d d „ Z d d d d „ Z d S(   iÿÿÿÿN(   t
   get_loader(   t   PyGIDeprecationWarning(   t   CallableInfo(   t	   TYPE_NONEt   TYPE_INVALID(   t   extend_pathc            s   ‡  f d †  } | S(   Nc            s   ˆ  j  |  _  ˆ  j |  _ |  S(   N(   t   __name__t
   __module__(   t   wrapper(   t   wrapped(    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyt   assign   s    (    (   R	   R
   (    (   R	   s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyt   wraps   s    t   OverridesProxyModulec           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s7   Wraps a introspection module and contains all overridesc         C   s&   t  t |  ƒ j | j ƒ | |  _ d  S(   N(   t   superR   t   __init__R   t   _introspection_module(   t   selft   introspection_module(    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyR   !   s    
c         C   s   t  |  j | ƒ S(   N(   t   getattrR   (   R   t   name(    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyt   __getattr__&   s    c         C   sK   t  t |  j ƒ ƒ } | j |  j j ƒ  ƒ | j t |  j ƒ ƒ t | ƒ S(   N(   t   sett   dirt	   __class__t   updatet   __dict__t   keysR   t   sorted(   R   t   result(    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyt   __dir__)   s    c         C   s   d t  |  ƒ j |  j f S(   Ns   <%s %r>(   t   typeR   R   (   R   (    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyt   __repr__/   s    (   R   R   t   __doc__R   R   R   R   (    (    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyR      s
   			t   _DeprecatedAttributec           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   sÉ   A 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         C   s2   | |  _  | |  _ t d | | | f ƒ |  _ d  S(   Ns#   %s.%s is deprecated; use %s instead(   t   _attrt   _valueR   t   _warning(   R   t	   namespacet   attrt   valuet   replacement(    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyR   :   s
    		c         C   s;   | d  k r t |  j ƒ ‚ n  t j |  j d d ƒ|  j S(   Nt
   stackleveli   (   t   Nonet   AttributeErrorR"   t   warningst   warnR$   R#   (   R   t   instancet   owner(    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyt   __get__A   s    c         C   s0   |  j  } t t | ƒ | ƒ t | | | ƒ d  S(   N(   R"   t   delattrR   t   setattr(   R   R.   R'   R&   (    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyt   __set__G   s    	c         C   s   t  t | ƒ |  j ƒ d  S(   N(   R1   R   R"   (   R   R.   (    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyt
   __delete__M   s    (   R   R   R    R   R0   R3   R4   (    (    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyR!   3   s
   			c         C   s  |  j  j d d ƒ d } d | } | t j k } t j j | ƒ } t | d t f i  ƒ } | |  ƒ } | t j | <d d l m } | | | <zW d | } y t | ƒ }	 Wn t	 k
 rÆ d	 }	 n X|	 d	 k r× |  St j | ƒ }
 Wd	 | | =t j | =| r| t j | <n  X| | _ g  } t |
 d
 ƒ r<|
 j } n  xN | D]F } y t |
 | ƒ } Wn t	 t f k
 rxqCn Xt | | | ƒ qCWx‰ t j | g  ƒ D]u \ } } y t | | ƒ } Wn! t	 k
 rât d | ƒ ‚ n Xt | | ƒ t | | | | ƒ } t | | | ƒ q W| S(   s¿   Loads 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.
    t   .i   iÿÿÿÿs   gi.repository.t   ProxyModulei   (   t   moduless   gi.overrides.Nt   __all__s1   %s was set deprecated but wasn't added to __all__(   R   t   rsplitt   sysR7   t   getR   R   t   importerR    R+   R*   t	   importlibt   import_modulet   _overrides_modulet   hasattrR8   R   t	   TypeErrorR2   t   _deprecated_attrst   popt   AssertionErrorR1   R!   (   R   R%   t
   module_keyt   has_oldt
   old_modulet
   proxy_typet   proxyR7   t   override_package_namet   override_loadert   override_modt   override_allt   vart   itemR&   R(   R'   t   deprecated_attr(    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyt   load_overridesR   sV    




	t   overridefuncc           B   s    e  Z d  Z d „  Z d „  Z RS(   s#   decorator for overriding a functionc         C   sS   t  | t ƒ s" t d | ƒ ‚ n  | j j d d ƒ d } t j d | |  _ d  S(   Ns"   func must be a gi function, got %sR5   i   iÿÿÿÿs   gi.repository.(   t
   isinstanceR   RA   R   R9   R:   R7   t   module(   R   t   funct   module_name(    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyR   ª   s    c         C   s   t  |  j | j | ƒ | S(   N(   R2   RT   R   (   R   RU   (    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyt   __call__±   s    (   R   R   R    R   RW   (    (    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyRR   ¨   s   	c         C   só   t  |  t j t f ƒ r" t |  ƒ Sy t |  d ƒ } Wn$ t k
 r[ t d |  j ƒ ‚ n X|  j	 j
 d ƒ sŠ t d |  |  j	 f ƒ ‚ n  | j ƒ  } | t k r® |  | _ n  |  j	 j d d ƒ d } t j d | } t | |  j |  ƒ |  Sd	 S(
   s  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.
    t   __info__sK   Can not override a type %s, which is not in a gobject introspection typelibs   gi.overridessU   You have tried override outside of the overrides module. This is not allowed (%s, %s)R5   i   iÿÿÿÿs   gi.repository.N(   RS   t   typest   FunctionTypeR   RR   R   R+   RA   R   R   t
   startswitht   KeyErrort
   get_g_typeR   t   pytypeR9   R:   R7   R2   (   t   type_t   infot   g_typeR%   RT   (    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyt   override¶   s&    
c            s"   t  ˆ  ƒ ‡  ‡ f d †  ƒ } | S(   s7   Decorator for marking methods and classes as deprecatedc             s0   t  j d ˆ  j ˆ f t d d ƒˆ  |  | Ž  S(   Ns    %s is deprecated; use %s insteadR)   i   (   R,   R-   R   R   (   t   argst   kwargs(   t   fnR(   (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyR	   Û   s    (   R   (   Re   R(   R	   (    (   Re   R(   s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyt
   deprecatedÙ   s    c         C   s#   t  j |  g  ƒ j | | f ƒ d S(   s:  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(   RB   t
   setdefaultt   append(   R%   R&   R(   (    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyRP   ã   s    i   c            s%   ‡  ‡ ‡ ‡ ‡ ‡ ‡ f d †  } | S(   s  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   	         sÐ  | rK t  j d d j ˆ  t | ƒ  ƒ ˆ d ˆ ƒt t ˆ  | ƒ ƒ } n i  } | j | ƒ g  } xI ˆ j ƒ  D]; \ } } | | k rq | j | ƒ | | <| j	 | ƒ qq qq W| rt  j d d j ‡ f d †  t
 | ƒ Dƒ ƒ d j t
 | ƒ ƒ f ˆ d ˆ ƒn  g  } xD ˆ j ƒ  D]6 \ } } | | k rˆ | | | <| j	 | ƒ qqW| r–t  j d d j ‡ f d †  t
 | ƒ Dƒ ƒ ˆ d ˆ ƒn  x* ˆ D]" } | | k r| j | ƒ qqWˆ |  |  S(   s†   Initializer for a GObject based classes with support for property
        sets through the use of explicit keyword arguments.
        sÒ   Using 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/InitializerDeprecationss   , R)   s…   The keyword(s) "%s" have been deprecated in favor of "%s" respectively. See: https://wiki.gnome.org/PyGObject/InitializerDeprecationsc         3   s   |  ] } ˆ  | Vq d  S(   N(    (   t   .0t   k(   t   deprecated_aliases(    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pys	   <genexpr>/  s    s   Initializer is relying on deprecated non-standard defaults. Please update to explicitly use: %s See: https://wiki.gnome.org/PyGObject/InitializerDeprecationsc         3   s#   |  ] } d  | ˆ  | f Vq d S(   s   %s=%sN(    (   Ri   Rj   (   t   deprecated_defaults(    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pys	   <genexpr>>  s    (   R,   R-   t   joint   lent   dictt   zipR   t   itemsRC   Rh   R   (	   R   Rc   Rd   t
   new_kwargst   aliases_usedt   keyt   aliast   defaults_usedR'   (   t	   arg_namest   categoryRk   Rl   t   ignoreR)   t   super_init_func(    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyt   new_init  s<    		"	#(    (   Rz   Rw   Ry   Rk   Rl   Rx   R)   R{   (    (   Rw   Rx   Rk   Rl   Ry   R)   Rz   s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyt   deprecated_init÷   s    !3c            s(   t  ˆ ƒ ‡  ‡ ‡ ‡ f d †  ƒ } | S(   s  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             sa   ˆ |  | Ž  } | d r> t  | ƒ d k r3 | d S| d Sn ˆ rY ˆ ˆ  pP d ƒ ‚ n  ˆ Sd  S(   Ni    i   i   s   call failed(   Rn   (   Rc   Rd   t   ret(   t   exc_strt   exc_typet   fail_rett   method(    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyR	   R  s    
(   R   (   R   R   R~   R€   R	   (    (   R~   R   R€   R   s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyt   strip_boolean_resultK  s    $(   RY   R,   R=   R:   t   pkgutilR    t   giR   t   gi._giR   t   gi._constantsR   R   R   t   __path__R   RB   R   t
   ModuleTypeR   t   objectR!   RQ   RR   Rb   Rf   RP   t   tupleR|   R*   R‚   (    (    (    s;   /usr/lib64/python2.7/site-packages/gi/overrides/__init__.pyt   <module>   s.   		V	#	
	Q