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 dZ,Gddde-Z.ddZ/dS))absolute_importN)Lock) maketrans) Repository FunctionInfoRegisteredTypeInfoEnumInfo ObjectInfo InterfaceInfo ConstantInfo StructInfo UnionInfo CallbackInfoStructBoxed CCallbackenum_addenum_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_typepytypeobject get_namespaceget_name importlib import_modulegetattr) object_infoZparent_object_infoZgtype namespacenamemoduler-/usr/lib64/python3.6/module.pyget_parent_for_objectLs r/cCsHg}x>|jD]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 ddZddZddZd 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|jdg|_|jdkr`tj |j|_t |_ dS)z"Might raise gi._gi.RepositoryErrorzgi.repository.zUTF-8N) repositoryZrequire _namespaceZ_version__name__get_typelib_path__path__ _have_py3decodeZ get_versionr_lock)selfr*versionpathr-r-r.__init__vs    zIntrospectionModule.__init__c stj|j|}|s$td|j|ft|tr"|j}|j|j }|dkr|j rv|j t rlt |}qt|}n|j trt|}nt|}||_d|j|_tdd}x2|jD]&}|jj|}t||||jqWx|jD]}t||j|qW|tkr||_ WdQRXnt|tr|j}t|trtt|t fddt!|D} f| } t"} nt|t#rt$f} t"} nt|t%rt&f} t"} ntt|t't(fr|j t)rt*f} nB|j t+s|tks|j,|krt-f} nt.d|j|j/ft0} nt1||jf|tkrR|j } | dk rR| | krR| |j2|<| S|d|j|d} | || | }|tkr||_ WdQRXn0t|t3r|}nt|t4r|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_namer5AttributeErrorr6 isinstancer r!r;r"Zis_flagsZis_ar rrrrrrDr$rErZ get_valuesZget_name_unescaped translatesetattrZ get_valueZ get_methodsrr r r/tupler2rrrr rrrrrrZ fundamentalr TypeErrorr%rNotImplementedError__dict__r r)r<r+infoZg_typewrapperZascii_upper_transZ value_infoZ value_nameZ method_infor1bases 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|jjtj|j}|jdd|Dt |S)Ncss |]}t|ts|jVqdS)N)rGrr%)rArNr-r-r.rCsz.IntrospectionModule.__dir__..) setdir __class__updaterMkeysr4Z get_infosr5list)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_modulesgiZget_required_versionr3)r*r=r,r-r-r.get_introspection_module s   r`)0Z __future__rsysr&Z threadingr version_infor9rrFstringr_Z_girr r r r r rrrrrrrrrrrrtypesrrZ _constantsrrrrr Z get_defaultr4r^r/r2r#r3r`r-r-r-r.s&   P