U ^%@sddlmZddlZz djZWn ek r>ddlmZYnXddlZddlmZm Z m Z m Z m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZddlmZmZddlmZmZm Z m!Z!m"Z"e#Z$iZ%d d Z&d d Z'Gd dde(Z)ddZ*dS))absolute_importN) 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|}|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/lib/python3/dist-packages/gi/module.pyget_parent_for_objectHs 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_object_s r2c@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. NcCsRt||||_||_d||_t|j}|g|_|jdkrNt|j|_dS)z"Might raise gi._gi.RepositoryErrorr N) repositoryZrequire _namespaceZ_version__name__get_typelib_path__path__Z get_version)selfr*versionpathr-r-r.__init__rs    zIntrospectionModule.__init__cst|j|}|s$td|j|ft|tr |}|j}|dkr | rz| t rdt |}q|t ksptt|}n(| trt|}n|t kstt|}||_d||_tdd}|D]&}||}t||||q|D]}t||j|q|t kr||_nt|trx|}t|trrt|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|t ks|j,|krt-f} nt.d||/ft0} nt1||t krH|j} | dk rH| | krH| |j2|<| S|d|j|d} | || | }|t kr||_n0t|t3r|}nt|t4r|}nt1|||j2|<|S) Nz%r object has no attribute %rr ZabcdefgjhijklmnopqrstuvwxyzZABCDEFGJHIJKLMNOPQRSTUVWXYZc3s|]}t|s|VqdSN) issubclass).0Z interfaceparentr-r. s z2IntrospectionModule.__getattr__..z$unable to create a wrapper for %s.%s)__info__ __module__Z __gtype__)5r4Z find_by_namer5AttributeErrorr6 isinstancer r!r"Zis_flagsZis_arrrAssertionErrorrrrrrCr$rDrZ get_valuesZget_name_unescaped translatesetattrZ get_valueZ get_methodsrr r/tupler2rrrr rr rrrrZ fundamentalr TypeErrorr%rNotImplementedError__dict__rr )r9r+infoZg_typewrapperZascii_upper_transZ value_infoZ value_nameZ method_infor1bases metaclassZtype_Zdict_r-r@r. __getattr__s                            zIntrospectionModule.__getattr__cCst|j}d|j|fS)Nz )r4r7r5)r9r;r-r-r.__repr__s zIntrospectionModule.__repr__cCsFtt|j}||jt|j}|dd|Dt |S)Ncss |]}t|ts|VqdSr=)rFrr%)r?rNr-r-r.rBs z.IntrospectionModule.__dir__..) setdir __class__updaterMkeysr4Z get_infosr5list)r9resultZnamespace_infosr-r-r.__dir__s  zIntrospectionModule.__dir__)N)r6rD __qualname____doc__r<rRrSr[r-r-r-r.r3js  jr3cCs0|tkrt|St|}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_modules   r`)+Z __future__rr&rrEstringr_Z_girrrr r r r r rrrrrrrrrrtypesrrZ _constantsrrrrrZ get_defaultr4r^r/r2r#r3r`r-r-r-r.s  P