3 ��<_�1�@s�ddlZddlZddlZddlZddlmZddlmZddlm Z ddl m Z m Z ddlm Z e ee�ZiZdd�ZGd d �d ej�ZGd d �d e�Zd d�Zdd�ZeZdd�Zdd�Ze�iiedfdd�Zddd�ZdS)�N)� get_loader)�PyGIDeprecationWarning)� CallableInfo)� TYPE_NONE� TYPE_INVALID)� extend_pathcs�fdd�}|S)Ncs�j|_�j|_|S)N)�__name__� __module__)�wrapper)�wrapped�� /usr/lib64/python3.6/__init__.py�assignszwraps..assignr )r rr )r r �wrapss rcs8eZdZdZ�fdd�Zdd�Zdd�Zdd �Z�ZS) �OverridesProxyModulez7Wraps a introspection module and contains all overridescstt|�j|j�||_dS)N)�superr�__init__r�_introspection_module)�self�introspection_module)� __class__r r r!s zOverridesProxyModule.__init__cCs t|j|�S)N)�getattrr)r�namer r r � __getattr__&sz OverridesProxyModule.__getattr__cCs6tt|j��}|j|jj��|jt|j��t|�S)N)�set�dirr�update�__dict__�keysr�sorted)r�resultr r r �__dir__)szOverridesProxyModule.__dir__cCsdt|�j|jfS)Nz<%s %r>)�typerr)rr r r �__repr__/szOverridesProxyModule.__repr__) rr � __qualname__�__doc__rrr!r#� __classcell__r r )rr rs  rc@s0eZdZdZdd�Zdd�Zdd�Zdd �Zd S) �_DeprecatedAttributez�A 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� namespace�attr�value� replacementr r r r:s z_DeprecatedAttribute.__init__cCs(|dkrt|j��tj|jdd�|jS)N�)� stacklevel)�AttributeErrorr(�warnings�warnr*r))r�instance�ownerr r r �__get__As z_DeprecatedAttribute.__get__cCs$|j}tt|�|�t|||�dS)N)r(�delattrr"�setattr)rr4r-r,r r r �__set__Gsz_DeprecatedAttribute.__set__cCstt|�|j�dS)N)r7r"r()rr4r r r � __delete__Msz_DeprecatedAttribute.__delete__N)rr r$r%rr6r9r:r r r r r'3s r'cCs�|jjdd�d }d|}|tjk}tjj|�}t|dtfi�}||�}|tj|<ddlm}t|d�snt �|||<zHd|}y t |�} Wnt k r�d } YnX| d kr�|St j |�} Wd ||=tj|=|r�|tj|<X||_g} t| d �r�| j} xH| D]@} yt| | �} Wnt tfk �r.�w�YnXt|| | ��q�Wxptj|g�D]`\}}yt||�}Wn"t k �r�t d |��YnXt||�t||||�}t|||��qPW|S) z�Loads 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. �.�zgi.repository.Z ProxyModuler/)�modulesrz gi.overrides.N�__all__z1%s was set deprecated but wasn't added to __all__�����)r�rsplit�sysr=�getr"rZimporter�hasattr�AssertionErrorrr1� importlib� import_moduleZ_overrides_moduler>r� TypeErrorr8�_deprecated_attrs�popr7r')rr+Z module_keyZhas_oldZ old_moduleZ proxy_type�proxyr=Zoverride_package_nameZoverride_loaderZ override_modZ override_all�var�itemr,r.r-�deprecated_attrr r r �load_overridesRsX            rNc st|t�r>|}|jjdd�d }tjd|��fdd�}|St|tj�rXtd|��n�yt |d�}Wn"t k r�td|j ��YnX|jj d �s�t d ||jf��|j�}|tks�t�|tkr�||_|jjdd�d }tjd|�t�|j |�|Sd 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<zgi.repository.cst�|j|�|S)N)r8r)�func)�moduler r r �szoverride..wrapperz"func must be a gi function, got %sZ__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)Nr?r?)� isinstancerr r@rAr=�types� FunctionTyperGrr1r� startswith�KeyErrorZ get_g_typerrDrZpytyper8)Ztype_rOr+r �infoZg_typer )rPr �override�s4     rWcst����fdd��}|S)z7Decorator for marking methods and classes as deprecatedcs$tjd�j�ftdd��||�S)Nz %s is deprecated; use %s insteadr/)r0)r2r3rr)�args�kwargs)�fnr.r r r �s zdeprecated..wrapped)r)rZr.r r )rZr.r � deprecated�sr[cCstj|g�j||f�dS)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)rH� setdefault�append)r+r,r.r r r rM�srMr/cs�������fdd�}|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 sZ|r:tjddj�dt|�����d�tt�|��}ni}|j|�g}x4�j�D](\}}||krV|j|�||<|j |�qVW|r�tjddj�fdd�t |�D��djt |��f��d�g}x2�j�D]&\}}||krΈ|||<|j |�q�W|�r*tjddj�fd d�t |�D����d�x"�D]}||k�r0|j|��q0W�|f|�S) z�Initializer for a GObject based classes with support for property sets through the use of explicit keyword arguments. z�Using 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, N)r0z�The keyword(s) "%s" have been deprecated in favor of "%s" respectively. See: https://wiki.gnome.org/PyGObject/InitializerDeprecationsc3s|]}�|VqdS)Nr )�.0�k)�deprecated_aliasesr r � /sz4deprecated_init..new_init..z�Initializer is relying on deprecated non-standard defaults. Please update to explicitly use: %s See: https://wiki.gnome.org/PyGObject/InitializerDeprecationsc3s|]}d|�|fVqdS)z%s=%sNr )r^r_)�deprecated_defaultsr r ra>s) r2r3�join�len�dict�zipr�itemsrIr]r) rrXrYZ new_kwargsZ aliases_used�key�aliasZ defaults_usedr-)� arg_names�categoryr`rb�ignorer0�super_init_funcr r �new_inits<       z!deprecated_init..new_initr )rmrjrlr`rbrkr0rnr )rjrkr`rbrlr0rmr �deprecated_init�s3rocst������fdd��}|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. csL�||�}|dr4t|�dkr&|dS|dd�Sn�rD��p@d���SdS)Nrr/r<z call failed)rd)rXrY�ret)�exc_str�exc_type�fail_ret�methodr r r Rs   z%strip_boolean_result..wrapped)r)rtrrrqrsr r )rqrrrsrtr �strip_boolean_resultKs ru)NNN)rRr2rErAZpkgutilrZgirZgi._girZ gi._constantsrrr�__path__rrHr� ModuleTyper�objectr'rNrWZ overridefuncr[rM�tuplerorur r r r �s.     V-  Q