o T`2@sddlZddlZddlZddlZddlZddlmZddlmZddl m Z m Z ddl m Z mZddlmZeeeZiZGdddejZGd d d eZd d Zd dZeZ ddZddZeiiedfddZdddZddZdS)N) get_loader)PyGIDeprecationWarning) CallableInfopygobject_new_full) TYPE_NONE TYPE_INVALID) extend_pathcs8eZdZdZfddZddZddZdd ZZS) OverridesProxyModulez7Wraps a introspection module and contains all overridescstt||j||_dSN)superr __init____name___introspection_module)selfintrospection_module __class__7/usr/lib/python3/dist-packages/gi/overrides/__init__.pyr s  zOverridesProxyModule.__init__cCs t|j|Sr )getattrr)rnamerrr __getattr__s z OverridesProxyModule.__getattr__cCs6tt|j}||j|t|jt|Sr )setdirrupdate__dict__keysrsorted)rresultrrr__dir__"szOverridesProxyModule.__dir__cCsdt|j|jfS)Nz<%s %r>)typer r)rrrr__repr__(szOverridesProxyModule.__repr__) r __module__ __qualname____doc__r rrr! __classcell__rrrrr s  r c@s0eZdZdZddZddZddZdd Zd S) _DeprecatedAttributezA deprecation descriptor for OverridesProxyModule subclasses. Emits a PyGIDeprecationWarning on every access and tries to act as a normal instance attribute (can be replaced and deleted). cCs$||_||_td|||f|_dS)Nz#%s.%s is deprecated; use %s instead)_attr_valuer_warning)r namespaceattrvalue replacementrrrr 3s z_DeprecatedAttribute.__init__cCs(|dur t|jtj|jdd|jS)N stacklevel)AttributeErrorr'warningswarnr)r()rinstanceownerrrr__get__:s z_DeprecatedAttribute.__get__cCs$|j}tt||t|||dSr )r'delattrr setattr)rr4r,r+rrr__set__@sz_DeprecatedAttribute.__set__cCstt||jdSr )r7r r')rr4rrr __delete__Fsz_DeprecatedAttribute.__delete__N)r r"r#r$r r6r9r:rrrrr&,s  r&c Cs|jddd}d|}|tjv}tj|}t|dtfi}||}|tj|<ddlm}t|ds7J|||<zAd |}zt |} Wn t yQd } Ynw| d urh|W||=tj|=|rg|tj|<SSt |} W||=tj|=|r||tj|<n||=tj|=|r|tj|<w||_ g} t| d r| j} | D]} zt| | } Wn t tfyYqwt|| | qt|gD]+\}}zt||}Wn t ytd |wt||t||||}t|||q|S) zLoads overrides for an introspection module. Either returns the same module again in case there are no overrides or a proxy module including overrides. Doesn't cache the result. .gi.repository. ProxyModuler.)modulesrz gi.overrides.N__all__z1%s was set deprecated but wasn't added to __all__)r rsplitsysr@getr r importerhasattrrr1 importlib import_module_overrides_modulerAr TypeErrorr8_deprecated_attrspopAssertionErrorr7r&)rr* module_keyhas_old old_module proxy_typeproxyr@override_package_nameoverride_loader override_mod override_allvaritemr+r-r,deprecated_attrrrrload_overridesKsv             rZcst|tr|}|jddd}tjd|fdd}|St|tjr+td|zt |d}Wnt y@td |j w|j d sPt d ||jf|}|tksZJ|tkra||_|jddd}tjd|t|j ||S) aDecorator for registering an override. Other than objects added to __all__, these can get referenced in the same override module via the gi.repository module (get_parent_for_object() does for example), so they have to be added to the module immediately. r;r<r=r>cst|j||Sr )r8r funcmodulerrwrapperszoverride..wrapperz"func must be a gi function, got %s__info__zKCan not override a type %s, which is not in a gobject introspection typelibz gi.overrideszUYou have tried override outside of the overrides module. This is not allowed (%s, %s)) isinstancerr"rBrCr@types FunctionTyperJrr1r startswithKeyError get_g_typerrpytyper8)type_r\r*r_infog_typerr]roverrides>       rkcstfdd}|S)z7Decorator for marking methods and classes as deprecatedcs(tjdjftdd|i|S)Nz %s is deprecated; use %s insteadr.r/)r2r3r r)argskwargsfnr-rrwrappedszdeprecated..wrapped functoolswraps)ror-rprrnr deprecatedsrtcCst|g||fdS)a:Marks a module level attribute as deprecated. Accessing it will emit a PyGIDeprecationWarning warning. e.g. for ``deprecated_attr("GObject", "STATUS_FOO", "GLib.Status.FOO")`` accessing GObject.STATUS_FOO will emit: "GObject.STATUS_FOO is deprecated; use GLib.Status.FOO instead" :param str namespace: The namespace of the override this is called in. :param str namespace: The attribute name (which gets added to __all__). :param str replacement: The replacement text which will be included in the warning. N)rK setdefaultappend)r*r+r-rrrrYsrYr.csfdd}|S)aWrapper for deprecating GObject based __init__ methods which specify defaults already available or non-standard defaults. :param callable super_init_func: Initializer to wrap. :param list arg_names: Ordered argument name list. :param list ignore: List of argument names to ignore when calling the wrapped function. This is useful for function which take a non-standard keyword that is munged elsewhere. :param dict deprecated_aliases: Dictionary mapping a keyword alias to the actual g_object_newv keyword. :param dict deprecated_defaults: Dictionary of non-standard defaults that will be used when the keyword is not explicitly passed. :param Exception category: Exception category of the error. :param int stacklevel: Stack level for the deprecation passed on to warnings.warn :returns: Wrapped version of ``super_init_func`` which gives a deprecation warning when non-keyword args or aliases are used. :rtype: callable c sL|rtjdddt|dtt|}ni}||g}D]\}}||vr>||||<| |q*|r^tjddfddt |Ddt |fdg}D]\}}||vrw|||<| |qd|rtjddfd dt |DdD] }||vr||q|fi|S) zInitializer for a GObject based classes with support for property sets through the use of explicit keyword arguments. zUsing positional arguments with the GObject constructor has been deprecated. Please specify keyword(s) for "%s" or use a class specific constructor. See: https://wiki.gnome.org/PyGObject/InitializerDeprecationsz, Nr/zThe keyword(s) "%s" have been deprecated in favor of "%s" respectively. See: https://wiki.gnome.org/PyGObject/InitializerDeprecationsc3s|]}|VqdSr r.0k)deprecated_aliasesrr (sz4deprecated_init..new_init..zInitializer is relying on deprecated non-standard defaults. Please update to explicitly use: %s See: https://wiki.gnome.org/PyGObject/InitializerDeprecationsc3s |] }d||fVqdS)z%s=%sNrrw)deprecated_defaultsrrr{7s) r2r3joinlendictzipritemsrLrvr) rrlrm new_kwargs aliases_usedkeyalias defaults_usedr, arg_namescategoryrzr|ignorer0super_init_funcrrnew_initsP      z!deprecated_init..new_initr)rrrrzr|rr0rrrrdeprecated_inits3rcs tfdd}|S)aTranslate method's return value for stripping off success flag. There are a lot of methods which return a "success" boolean and have several out arguments. Translate such a method to return the out arguments on success and None on failure. csJ|i|}|drt|dkr|dS|ddSr#p!dS)Nrr.r<z call failed)r~)rlrmretexc_strexc_typefail_retmethodrrrpKs   z%strip_boolean_result..wrappedrq)rrrrrprrrstrip_boolean_resultDs rcsfdd}|S)Ncs&t|d}t|d}||g|RS)NF)r)ab user_datar[rrwrap\s  z'wrap_list_store_sort_func..wrapr)r\rrr[rwrap_list_store_sort_funcZs r)NNN) rrrbr2rGrCpkgutilrgirgi._girr gi._constantsrrr__path__r rK ModuleTyper objectr&rZrk overridefuncrtrYtuplerrrrrrrs6    V-  T