3 ��<_Q(� @sddlmZddlZddlZddlmZejddkZy djZWn e k r`ddl mZYnXddl Z ddl m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZdd lm Z m!Z!dd l"m#Z#m$Z$m%Z%m&Z&m'Z'e j(�Z)iZ*d d �Z+d d�Z,Gdd�de-�Z.dd�Z/dS)�)�absolute_importN)�Lock��)� maketrans�)� Repository� FunctionInfo�RegisteredTypeInfo�EnumInfo� ObjectInfo� InterfaceInfo� ConstantInfo� StructInfo� UnionInfo� CallbackInfo�Struct�Boxed� CCallback�enum_add�enum_register_new_gtype_and_add� flags_add� flags_register_new_gtype_and_add� GInterface)� GObjectMeta� StructMeta)� TYPE_NONE� TYPE_BOXED� TYPE_POINTER� TYPE_ENUM� TYPE_FLAGScCsP|j�}|s(|j�}|r$|jr$|jStS|j�}|j�}tjd|�}t||�S)Nzgi.repository.) Z get_parent� get_g_type�pytype�object� get_namespace�get_name� importlib� import_module�getattr)� object_infoZparent_object_infoZgtype� namespace�name�module�r-�/usr/lib64/python3.6/module.py�get_parent_for_objectLs r/cCsHg}x>|j�D]2}|j�}|j�}tjd|�}|jt||��qW|S)Nzgi.repository.)Zget_interfacesr$r%r&r'�appendr()r)� interfacesZinterface_infor*r+r,r-r-r.�get_interfaces_for_objectcsr2c@s2eZdZdZd dd�Zdd�Zdd�Zd d �ZdS) �IntrospectionModuleaUAn 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. NcCsltj||�||_||_d||_tj|j�}|g|_trH|jd�g|_|jdkr`tj |j�|_t �|_ dS)z"Might raise gi._gi.RepositoryErrorzgi.repository.zUTF-8N) � repositoryZrequire� _namespaceZ_version�__name__�get_typelib_path�__path__� _have_py3�decodeZ get_versionr�_lock)�selfr*�version�pathr-r-r.�__init__vs    zIntrospectionModule.__init__c s�tj|j|�}|s$td|j|f��t|t��r"|j�}|j��|j }|dk�r|j �rv|j t �rlt |�}q�t|�}n|j t�r�t|�}nt|�}||_d|j�|_tdd�}x2|j�D]&}|j�j|�}t||||j���q�Wx|j�D]}t||j|�q�W|tk�r||_ WdQRX�n�t|t��r�|j�}t|t��rtt|��t �fdd�t!|�D��} �f| } t"} n�t|t#��r�t$f} t"} n�t|t%��r�t&f} t"} ntt|t't(f��r|j t)��r�t*f} nB|j t+��s�|tk�s�|j,|k�r�t-f} nt.d|j�|j/�f��t0} nt1|��|j�f|tk�rR|j } | dk �rR| | k�rR| |j2|<| S|d|j|d�} | || | �}|tk�r�||_ WdQRXn0t|t3��r�|}nt|t4��r�|j�}nt1|��||j2|<|S) Nz%r object has no attribute %rzgi.repository.ZabcdefgjhijklmnopqrstuvwxyzZABCDEFGJHIJKLMNOPQRSTUVWXYZc3s|]}t�|�s|VqdS)N)� issubclass)�.0Z interface)�parentr-r.� �sz2IntrospectionModule.__getattr__..z$unable to create a wrapper for %s.%s)�__info__� __module__Z __gtype__)5r4Z find_by_namer5�AttributeErrorr6� isinstancer r!r;r"Zis_flagsZis_ar rrrrrrDr$rErZ get_valuesZget_name_unescaped� translate�setattrZ get_valueZ get_methodsrr r r/�tupler2rrrr rrrrrrZ fundamentalr� TypeErrorr%r�NotImplementedError�__dict__r r)r<r+�infoZg_type�wrapperZascii_upper_transZ value_infoZ value_nameZ method_infor1�bases� metaclassZtype_Zdict_r-)rBr.� __getattr__�s�                         zIntrospectionModule.__getattr__cCs(tj|j�}tr|jd�}d|j|fS)NzUTF-8z )r4r7r5r9r:)r<r>r-r-r.�__repr__�s  zIntrospectionModule.__repr__cCsFtt|j��}|j|jj��tj|j�}|jdd�|D��t |�S)Ncss |]}t|t�s|j�VqdS)N)rGrr%)rArNr-r-r.rCsz.IntrospectionModule.__dir__..) �set�dir� __class__�updaterM�keysr4Z get_infosr5�list)r<�resultZnamespace_infosr-r-r.�__dir__�s  zIntrospectionModule.__dir__)N)r6rE� __qualname__�__doc__r?rRrSr[r-r-r-r.r3ns  lr3cCs0|tkrt|Stj|�}t||�}|t|<|S)z� :Returns: An object directly wrapping the gi module without overrides. Might raise gi._gi.RepositoryError )�_introspection_modules�giZget_required_versionr3)r*r=r,r-r-r.�get_introspection_module s   r`)0Z __future__r�sysr&Z threadingr� version_infor9rrF�stringr_Z_girr r r r r rrrrrrrrrrrr�typesrrZ _constantsrrrrr Z get_defaultr4r^r/r2r#r3r`r-r-r-r.�s&   P