
    gi!                         d dl Z d dlmZ d dlmZ d dlZddlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZmZ ddlmZmZmZ  ej<                         Zi Z d Z!d	 Z" G d
 de      Z#d Z$y)    N)Lock)
ModuleType   )
RepositoryFunctionInfoRegisteredTypeInfoEnumInfo
ObjectInfoInterfaceInfoConstantInfo
StructInfo	UnionInfoCallbackInfoStructBoxedFundamental	CCallbackenum_add	flags_add
GInterface)GObjectMeta
StructMeta)	TYPE_NONE
TYPE_BOXEDTYPE_POINTERc                 Z   | j                         }|sV| j                         }|r|j                  r|j                  S | j                         r|j	                         rt
        S t        S |j                         }|j                         }t        j                  d|z         }t        ||      S Ngi.repository.)
get_parent
get_g_typepytypeget_fundamentalis_instantiatabler   objectget_namespaceget_name	importlibimport_modulegetattr)object_infoparent_object_infogtype	namespacenamemodules         +/usr/lib/python3/dist-packages/gi/module.pyget_parent_for_objectr1   8   s    $//1 &&(U\\<<&&(U-D-D-F "002I&&(D$$%5	%ABF64      c                     g }| j                         D ]U  }|j                         }|j                         }t        j                  d|z         }|j                  t        ||             W |S r   )get_interfacesr%   r&   r'   r(   appendr)   )r*   
interfacesinterface_infor-   r.   r/   s         r0   get_interfaces_for_objectr8   R   sn    J%446 1"002	&&((()9I)EF'&$/01 r2   c                   :     e Zd ZdZd fd	Zd Zd Z fdZ xZS )IntrospectionModuleaU  An object which wraps an introspection typelib.

    This wrapping creates a python module like representation of the typelib
    using gi repository as a foundation. Accessing attributes of the module
    will dynamically pull them in and create wrappers for the members.
    These members are then cached on this introspection module.
    c                 >   t         j                  ||       t        |   d|        || _        || _        t         j                  | j                        }|g| _        | j
                  $t         j                  | j                        | _        t               | _
        y)z#Might raise gi._gi.RepositoryError.r   N)
repositoryrequiresuper__init__
_namespace_versionget_typelib_path__path__get_versionr   _lock)selfr-   versionpath	__class__s       r0   r?   zIntrospectionModule.__init__f   s{    9g.>)56#**4??;== &224??CDMV
r2   c                 2   t         j                  | j                  |      }|st        | j                  d|      t        |t              r|j                         }| j                  5  |j                  }|`|j                         rt        | |||      }nt        | |||      }||_        |j                         D ]  }t        ||j                  |        |t         k7  r||_	        d d d        nt        |t"              r|j                         }t        |t$              r5t'        |      t)        fdt+        |      D              }g|}t,        }nt        |t.              rt0        f}t,        }nt        |t2              rt4        f}t,        }nt        |t6        t8        f      r|j;                  t<              rt>        f}nb|j;                  t@              s|t         k(  s|jB                  |k(  rtD        f}n-tG        d|jI                          d|jK                                tL        }ntO        |      | j                  5  |t         k7  r,|j                  }	|	|	|vr|	| jP                  |<   |	cd d d        S || j                  |d}
 ||||
      }|t         k7  r||_	        d d d        n?t        |tR              r|}n,t        |tT              r|jW                         }ntO        |      | jP                  |<   |S # 1 sw Y   xY w# 1 sw Y   &xY w)Nz object has no attribute c              3   :   K   | ]  }t        |      s|  y wN)
issubclass).0	interfaceparents     r0   	<genexpr>z2IntrospectionModule.__getattr__.<locals>.<genexpr>   s#      #!%fi8 #s   zunable to create a wrapper for .)__info__
__module__	__gtype__),r<   find_by_namer@   AttributeError__name__
isinstancer	   r    rE   r!   is_flagsr   r   rS   get_methodssetattrr   r   r
   r1   tupler8   r   r   r   r   r   r   r   is_ar   r   r   fundamentalr   	TypeErrorr%   r&   r   NotImplementedError__dict__r   r   	get_value)rF   r.   infog_typewrappermethod_infor6   bases	metaclasstype_dict_rP   s              @r0   __getattr__zIntrospectionModule.__getattr__u   s   &&t= DMM#44MdX!VWWdH%__&F , --?}}"+D$"E"*4vt"D'+G$'+'7'7'9 L)=)={KL Y&$+FM, ,  01__&F $
+.t4" #%>t%D# 

  -*-'	D,/"'	D-0#'	D:y"9:;;z*"HEKK-*))V3#IE#9$:L:L:N9OqQUQ^Q^Q`Pab  '	)$// , Y&"MME(U%-?.3d+$, , !%"&--!'
 $D%7 Y&$+FM+, ,. l+Gl+nn&G%d++
 &dm, ,h, ,s   *A?L,L>*LL
Lc                 f    t         j                  | j                        }d| j                  d|dS )Nz<IntrospectionModule z from >)r<   rB   r@   )rF   rH   s     r0   __repr__zIntrospectionModule.__repr__   s0    **4??;&t&9xqIIr2   c                     t        t        | 	               }t        j	                  | j
                        }|j                  d |D               t        |      S )Nc              3   \   K   | ]$  }t        |t              s|j                          & y wrL   )rY   r   r&   )rN   rd   s     r0   rQ   z.IntrospectionModule.__dir__.<locals>.<genexpr>   s(      
dL1 MMO
s   *,)setr>   __dir__r<   	get_infosr@   updatelist)rF   resultnamespace_infosrI   s      r0   rs   zIntrospectionModule.__dir__   sO    UW_&' %..t? 
'
 	
 F|r2   rL   )	rX   rT   __qualname____doc__r?   rl   ro   rs   __classcell__)rI   s   @r0   r:   r:   ]   s$    ^@J r2   r:   c                 |    | t         v r	t         |    S t        j                  |       }t        | |      }|t         | <   |S )z{:Returns:
        An object directly wrapping the gi module without overrides.

    Might raise gi._gi.RepositoryError
    )_introspection_modulesgiget_required_versionr:   )r-   rG   r/   s      r0   get_introspection_moduler      sD     **%i00%%i0G G4F(.9%Mr2   )%r'   	threadingr   typesr   r~   _gir   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   
_constantsr   r   r   get_defaultr<   r}   r1   r8   r:   r    r2   r0   <module>r      so   (    	    & + ; ; $Z##%
  !4J* JZr2   