ó
#ŠNc           @   sp   d  d l  Z  d  d l Z d  d l m Z d Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ	 e ƒ  Z d „  Z
 d S(   iÿÿÿÿN(   t   _gobjectt	   _Registryc           B   s   e  Z d  „  Z d „  Z RS(   c         C   sæ   | | k s t  d ƒ ‚ n  t | d ƒ } | d k rL t  d | j ƒ ‚ n  | j j d ƒ sm t  d ƒ ‚ n  | j ƒ  } | t j k sŽ t	 ‚ | t j
 k râ | | _ | j d } d | | j f } t t |  ƒ j | | ƒ n  d S(	   ss  We do checks here to make sure only submodules of the override 
        module are added.  Key and value should be the same object and come
        from the gi.override module.  

        We add the override to the dict as "override_module.name".  For instance
        if we were overriding Gtk.Button you would retrive it as such:
        registry['Gtk.Button']
        sZ   You have tried to modify the registry.  This should only be done by the override decoratort   __info__sK   Can not override a type %s, which is not in a gobject introspection typelibs   gi.overridess[   You have tried to modify the registry outside of the overrides module.  This is not allowedi   s   %s.%sN(   t   KeyErrort   getattrt   Nonet   __name__t
   __module__t
   startswitht
   get_g_typeR    t	   TYPE_NONEt   AssertionErrort   TYPE_INVALIDt   pytypet   superR   t   __setitem__(   t   selft   keyt   valuet   infot   g_typet   module(    (    s9   /usr/lib/python2.7/dist-packages/gi/overrides/__init__.pyR      s    		c         C   s   | |  | <d  S(   N(    (   R   t   override_class(    (    s9   /usr/lib/python2.7/dist-packages/gi/overrides/__init__.pyt   register%   s    (   R   R   R   R   (    (    (    s9   /usr/lib/python2.7/dist-packages/gi/overrides/__init__.pyR      s   	t   overridefuncc           B   s    e  Z d  Z d „  Z d „  Z RS(   s#   decorator for overriding a functionc         C   sE   t  | d ƒ s t d ƒ ‚ n  d d l m } | | j j |  _ d  S(   NR   s   func must be an gi functioni   (   t   modules(   t   hasattrt	   TypeErrort   importerR   R   t   _introspection_moduleR   (   R   t   funcR   (    (    s9   /usr/lib/python2.7/dist-packages/gi/overrides/__init__.pyt   __init__+   s    c            s5   ‡  f d †  } ˆ  j  | _  t |  j ˆ  j  | ƒ | S(   Nc             s   ˆ  |  | Ž  S(   N(    (   t   argst   kwargs(   R   (    s9   /usr/lib/python2.7/dist-packages/gi/overrides/__init__.pyt   wrapper2   s    (   R   t   setattrR   (   R   R   R"   (    (   R   s9   /usr/lib/python2.7/dist-packages/gi/overrides/__init__.pyt   __call__1   s    (   R   R   t   __doc__R   R$   (    (    (    s9   /usr/lib/python2.7/dist-packages/gi/overrides/__init__.pyR   )   s   	c         C   s4   t  |  ƒ t j k r t |  ƒ St j |  ƒ |  Sd S(   s%   Decorator for registering an overrideN(   t   typet   typest   FunctionTypeR   t   registryR   (   t   type_(    (    s9   /usr/lib/python2.7/dist-packages/gi/overrides/__init__.pyt   override:   s    
(   t   sysR'   t   giR    R   R)   t   dictR   t   objectR   R+   (    (    (    s9   /usr/lib/python2.7/dist-packages/gi/overrides/__init__.pyt   <module>   s   "	