o b^M%@sddlZddlZddlmZmZmZmZmZmZm Z m Z m Z m Z m Z mZmZmZmZmZmZmZddlmZmZddlmZmZmZmZmZeZiZ ddZ!dd Z"Gd d d e#Z$d d Z%dS)N) 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.) get_parent get_g_typepytypeobject get_namespaceget_name importlib import_modulegetattr) object_infoparent_object_infogtype namespacenamemoduler-+/usr/lib/python3/dist-packages/gi/module.pyget_parent_for_object@s  r/cCsDg}|D]}|}|}td|}|t||q|Sr)get_interfacesr"r#r$r%appendr&)r' interfacesinterface_infor*r+r,r-r-r.get_interfaces_for_objectWs r4c@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. NcCsVt||||_||_d||_t|j}|g|_|jdur)t|j|_dSdS)z"Might raise gi._gi.RepositoryErrorrN) repositoryrequire _namespace_version__name__get_typelib_path__path__ get_version)selfr*versionpathr-r-r.__init__js    zIntrospectionModule.__init__cst|j|}|std|j|ft|tr|}|j}|dur| r;| t r0t |}n|t ks6Jt|}n| trEt|}n |t ksKJt|}||_d||_ddd}|D]}||}t||||qc|D] }t||j|q{|t kr||_nt|tr1|}t|trt|tfddt |D} f| } t!} nKt|t"rt#f} t!} n@t|t$rt%f} t!} n5t|t&t'fr| t(rt)f} n| t*s|t ks|j+|krt,f} n t-d||.ft/} nt0||t kr|j} | dur| | vr| |j1|<| S|d|j|d } | || | }|t kr0||_nt|t2r:|}nt|t3rE|}nt0|||j1|<|S) Nz%r object has no attribute %rrabcdefgjhijklmnopqrstuvwxyzABCDEFGJHIJKLMNOPQRSTUVWXYZc3s|] }t|s|VqdSN) issubclass).0 interfaceparentr-r. sz2IntrospectionModule.__getattr__..z$unable to create a wrapper for %s.%s)__info__ __module__ __gtype__)4r6 find_by_namer8AttributeErrorr: isinstancerrr is_flagsis_arrrrrrrrLr"rM maketrans get_valuesget_name_unescaped translatesetattr get_value get_methodsrrr/tupler4rr rrrr r rrr fundamentalr TypeErrorr#rNotImplementedError__dict__rr )r>r+infog_typewrapperascii_upper_trans value_info value_name method_infor2bases metaclasstype_dict_r-rIr. __getattr__xs                          zIntrospectionModule.__getattr__cCst|j}d|j|fS)Nz )r6r;r8)r>r@r-r-r.__repr__s zIntrospectionModule.__repr__cCsFtt|j}||jt|j}|dd|Dt |S)Ncss"|] }t|ts|VqdSrE)rQr r#)rGr`r-r-r.rKsz.IntrospectionModule.__dir__..) setdir __class__updater_keysr6 get_infosr8list)r>resultnamespace_infosr-r-r.__dir__s  zIntrospectionModule.__dir__rE)r:rM __qualname____doc__rArkrlrvr-r-r-r.r5bs  j r5cCs0|tvrt|St|}t||}|t|<|S)z :Returns: An object directly wrapping the gi module without overrides. Might raise gi._gi.RepositoryError )_introspection_modulesgiget_required_versionr5)r*r?r,r-r-r.get_introspection_modules   r|)&r$rz_girrrrrrr r r r r rrrrrrrtypesrr _constantsrrrrr get_defaultr6ryr/r4r!r5r|r-r-r-r.sP