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 ƒr‚|j t ƒrlt |ƒ}qª|tksxt‚t|ƒ}n(|j tƒr–t|ƒ}n|tks¢t‚t|ƒ}||_d|jƒ|_tddƒ}x2|jƒD]&}|jƒj|ƒ}t||||jƒƒƒqÒWx |jƒD]}t||j|ƒ�qW|tk�r.||_ WdQRX�nšt|tƒ�r¦|jƒ}t|tƒ�rŽt |ƒ‰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ƒ|j0ƒfƒ‚t1} nt2|ƒ‚|j�f|tk�rl|j } | dk �rl| | k�rl| |j3|<| S|d|j|dœ} | || | ƒ}|tk�rš||_ WdQRXn0t|t4ƒ�r¸|}nt|t5ƒ�rÎ|jƒ}nt2|ƒ‚||j3|<|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__)6r4Z find_by_namer5ÚAttributeErrorr6Ú isinstancer r!r;r"Zis_flagsZis_ar rrÚAssertionErrorrrrrrDr$rErZ get_valuesZget_name_unescapedÚ translateÚsetattrZ get_valueZ get_methodsr 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%)rArOr-r-r.rCsz.IntrospectionModule.__dir__..) ÚsetÚdirÚ __class__ÚupdaterNÚkeysr4Z get_infosr5Úlist)r<ÚresultZnamespace_infosr-r-r.Ú__dir__üs  zIntrospectionModule.__dir__)N)r6rEÚ __qualname__Ú__doc__r?rSrTr\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   ra)0Z __future__rÚsysr&Z threadingrÚ version_infor9rrFÚstringr`Z_girr r r r r rrrrrrrrrrrrÚtypesrrZ _constantsrrrrr Z get_defaultr4r_r/r2r#r3rar-r-r-r.Ús&   P