a 6Uc&@sddlZddlmZddlZddlmZmZmZmZm Z m Z m Z m Z m Z mZmZmZmZmZmZmZmZmZddlmZmZddlmZmZmZmZmZe Z!iZ"ddZ#d d Z$Gd d d e%Z&d dZ'dS)N)Lock) 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|}|s(|}|r$|jr$|jStS|}|}td|}t||SNgi.repository.) Z get_parent get_g_typepytypeobject get_namespaceget_name importlib import_modulegetattr) object_infoZparent_object_infoZgtype namespacenamemoduler+//usr/lib64/python3.9/site-packages/gi/module.pyget_parent_for_objectAs r-cCsDg}|D]2}|}|}td|}|t||q |Sr)Zget_interfacesr"r#r$r%appendr&)r' interfacesZinterface_infor(r)r*r+r+r,get_interfaces_for_objectXs r0c@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. NcCsZt||||_||_d||_t|j}|g|_|jdurNt|j|_t|_ dS)z"Might raise gi._gi.RepositoryErrorrN) repositoryZrequire _namespaceZ_version__name__get_typelib_path__path__Z get_versionr_lock)selfr(versionpathr+r+r,__init__ks    zIntrospectionModule.__init__cst|j|}|s$td|j|ft|trL|}|j|j }|dur| r| t rlt |}q|tksxJt|}n(| trt|}n|tksJt|}||_d||_ddd}|D]&}||}t||||q|D]}t||j|q|tkr(||_ Wdn1s>0Ynt|tr|}t|trt|t fddt!|D} f| } t"} nt|t#rt$f} t"} nt|t%rt&f} t"} ntt|t't(fr:| t)rt*f} nB| t+s|tks|j,|krt-f} nt.d||/ft0} nt1||j~|tkr|j } | dur| | vr| |j2|<| WdS|d|j|d } | || | }|tkr||_ Wdn1s0Yn0t|t3r|}nt|t4r|}nt1|||j2|<|S) Nz%r object has no attribute %rrZabcdefgjhijklmnopqrstuvwxyzZABCDEFGJHIJKLMNOPQRSTUVWXYZc3s|]}t|s|VqdSN) issubclass).0Z interfaceparentr+r, s z2IntrospectionModule.__getattr__..z$unable to create a wrapper for %s.%s)__info__ __module__Z __gtype__)5r2Z find_by_namer3AttributeErrorr4 isinstancerrr7r Zis_flagsZis_arrrrrrrrCr"rD maketransZ get_valuesZget_name_unescaped translatesetattrZ get_valueZ get_methodsrrr-tupler0rr rr rr r rrrZ fundamentalr TypeErrorr#rNotImplementedError__dict__rr )r8r)infoZg_typewrapperZascii_upper_transZ value_infoZ value_nameZ method_infor/bases metaclasstype_Zdict_r+r@r, __getattr__{s            *           (    zIntrospectionModule.__getattr__cCst|j}d|j|fS)Nz )r2r5r3)r8r:r+r+r,__repr__s zIntrospectionModule.__repr__cCsFtt|j}||jt|j}|dd|Dt |S)Ncss |]}t|ts|VqdSr=)rFr r#)r?rNr+r+r,rBs z.IntrospectionModule.__dir__..) setdir __class__updaterMkeysr2Z get_infosr3list)r8resultZnamespace_infosr+r+r,__dir__s  zIntrospectionModule.__dir__)N)r4rD __qualname____doc__r;rSrTr\r+r+r+r,r1cs  mr1cCs0|tvrt|St|}t||}|t|<|S)z :Returns: An object directly wrapping the gi module without overrides. Might raise gi._gi.RepositoryError )_introspection_modulesgiZget_required_versionr1)r(r9r*r+r+r,get_introspection_modules   ra)(r$ threadingrr`Z_girrrrrr r r r r rrrrrrrrtypesrrZ _constantsrrrrr get_defaultr2r_r-r0r!r1rar+r+r+r,s P