ok

Mini Shell

Direktori : /lib/python3.6/site-packages/dnf/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/dnf/__pycache__/plugin.cpython-36.pyc

3

��fV%�@s�ddlmZddlmZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlmZejd�ZdZGdd	�d	e�ZGd
d�de�Zdd
�Zdd�Zdd�Zdd�Zdd�ZdS)�)�absolute_import)�print_function)�unicode_literalsN)�_�dnfzdnf.plugin.dynamicc@s\eZdZdZdZdZedd��Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�ZdS)�Pluginz5The base class custom plugins must derive from. #:apiz	<invalid>Ncs�tjj�}|jr|jn|j��fdd�|jD�}xb|D]Z}tjj|�r6y|j	|�Wq6t
k
r�}ztjj
td�t|���WYdd}~Xq6Xq6W|S)Ncsg|]}d|�f�qS)z
%s/%s.conf�)�.0�path)�namer�/usr/lib/python3.6/plugin.py�
<listcomp>9sz&Plugin.read_config.<locals>.<listcomp>zParsing file failed: %s)�libdnf�confZConfigParser�config_namerZpluginconfpath�osr
�isfile�read�	Exceptionr�
exceptionsZConfigErrorr�str)�clsr�parser�files�file�er)rr�read_config4s

.zPlugin.read_configcCs||_||_dS)N)�base�cli)�selfrrrrr�__init__BszPlugin.__init__cCsdS)Nr)rrrr�
pre_configGszPlugin.pre_configcCsdS)Nr)rrrr�configKsz
Plugin.configcCsdS)Nr)rrrr�resolvedOszPlugin.resolvedcCsdS)Nr)rrrr�sackSszPlugin.sackcCsdS)Nr)rrrr�pre_transactionWszPlugin.pre_transactioncCsdS)Nr)rrrr�transaction[szPlugin.transaction)�__name__�
__module__�__qualname__�__doc__rr�classmethodrr r!r"r#r$r%r&rrrrr.src@s~eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	ddd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�PluginscCsg|_g|_dS)N)�
plugin_cls�plugins)rrrrr aszPlugins.__init__cCs|j�dS)N)�_unload)rrrr�__del__eszPlugins.__del__cCs~xx|jD]n}yt||��Wqtjjk
r6�Yqtk
rttj�\}}}tj	|||�}t
jdj|��YqXqWdS)N�)
r.�getattrrr�Errorr�sys�exc_info�	traceback�format_exception�loggerZcritical�join)r�method�plugin�exc_type�	exc_value�
exc_tracebackZexcept_listrrr�_callerhszPlugins._callercsxxr|jdd�D]`}|j�t�fdd�|D��r2q|j|�}|jd�o^|jdd�o^|jdd�}|r|jj|�qWdS)zwChecks whether plugins are enabled or disabled in configuration files
           and removes disabled plugins from listNc3s|]}tj�|�VqdS)N)�fnmatch)r	�pattern)rrr�	<genexpr>xsz)Plugins._check_enabled.<locals>.<genexpr>�mainZenabled)r-r�anyrZhas_sectionZ
has_optionZ
getboolean�remove)rr�enable_pluginsZplug_clsrZdisabledr)rr�_check_enabledss

zPlugins._check_enabledcCs�ttjkrtd��tjjt�tjt<}g|_t|j	||�}t
||�t�dd�|_|j
||�t|j�dkr�tdd�|jD��}tjtd�dj|��dS)z)Dynamically load relevant plugin modules.zload_plugins() called twiceNrcss|]}|jVqdS)N)r)r	r;rrrrB�sz Plugins._load.<locals>.<genexpr>zLoaded plugins: %sz, )�DYNAMIC_PACKAGEr4�modules�RuntimeErrorrZpycomp�
ModuleType�__path__�_get_plugins_filesZ
pluginpath�_import_modules�_plugin_classesr-rG�len�sortedr8�debugrr9)rrZskipsrF�packager�namesrrr�_load�s

z
Plugins._loadcCs|jd�dS)Nr!)r?)rrrr�_run_pre_config�szPlugins._run_pre_configcCs|jd�dS)Nr")r?)rrrr�_run_config�szPlugins._run_configNcCs*x$|jD]}|||�}|jj|�qWdS)N)r-r.�append)rrrZp_clsr;rrr�	_run_init�s
zPlugins._run_initcCs|jd�dS)Nr$)r?)rrrr�run_sack�szPlugins.run_sackcCs|jd�dS)Nr#)r?)rrrr�run_resolved�szPlugins.run_resolvedcCs|jd�dS)Nr%)r?)rrrr�run_pre_transaction�szPlugins.run_pre_transactioncCs|jd�dS)Nr&)r?)rrrr�run_transaction�szPlugins.run_transactioncCs&ttjkr"tjtjjd�tjt=dS)NzPlugins were unloaded.)rHr4rIr8�logr�loggingZDDEBUG)rrrrr/�s
zPlugins._unloadcCs�|js
dSt�}x|jD]}||tj|j�<qWt|j��}t�}x |jD]}|j|j	|j
��qJW|sldSx|jD]}|j|j
�qtWx|D]}|jj
||�q�WdS)zH
        Unload plugins that were removed in the `transaction`.
        N)Z
remove_set�dictr.�inspectZgetfile�	__class__�set�keys�update�intersectionrZinstall_set�difference_updaterE)rr&r.r;Zplugin_filesZerased_plugin_filesZpkgZplugin_filerrr�unload_removed_plugins�s
zPlugins.unload_removed_plugins)N)r'r(r)r r0r?rGrUrVrWrYrZr[r\r]r/rhrrrrr,`s
r,cCstj�S)N)r�__subclasses__rrrrrO�srOcCs�x�|D]�}tjj|�\}}|jj|�tjj|�\}}d|j|f}ytj|�}Wqt	k
r�}z,t
jtd�||�t
j
tjjddd�WYdd}~XqXqWdS)Nz%s.%szFailed loading plugin "%s": %sr1T)r5)rr
�splitrLrX�splitextr'�	importlib�
import_modulerr8�errorrr^rr_ZSUBDEBUG)rSZpy_files�fnr
�moduleZextrrrrrrN�s
rNcCsJg}t|�}t|�}t�}t�}x�|D]�}x�tjd|�D]�}tjjtjj|��\}}	d}
d}xN|D]F}t||�rd|j|�d}
x$|D]}
t||
�r�d}
|j|
�q�Wd}qdW|s�x |D]}
t||
�r�|j|
�q�W|
r:|j|�q:Wq&W|j	|�}|�rt
jtd�j
djt|����|j	|�}|�rFt
jtd�j
djt|����|S)Nz%s/*.pyTFz=No matches found for the following enable plugin patterns: {}z, z>No matches found for the following disable plugin patterns: {})rc�globrr
rk�basename�_plugin_name_matches_pattern�addrX�
differencer8Zwarningr�formatr9rQ)�pathsZdisable_pluginsrFr.Zpattern_enable_foundZpattern_disable_found�pro�plugin_nameZdummyZmatchedZenable_pattern_testedZpattern_skipZpattern_enableZenable_not_foundZdisable_not_foundrrrrM�sD









rMcs*t||jdd�f�}t�fdd�|D��S)z�
    Checks plugin name matches the pattern.

    The alternative plugin name using dashes instead of underscores is tried
    in case of original name is not matched.

    (see https://bugzilla.redhat.com/show_bug.cgi?id=1980712)
    r�-c3s|]}tj|��VqdS)N)r@)r	r)rArrrBsz/_plugin_name_matches_pattern.<locals>.<genexpr>)rc�replacerD)ryrAZ	try_namesr)rArrss
rscs<�fdd�}tt�jd�tjf|�jdd��}|�_�S)z5A class decorator for automatic command registration.cs|r|j��dS)N)�register_command)rrr)�
command_classrrr sz"register_command.<locals>.__init__rr)r r)�typerr'rr�aliasesZ_plugin)r}r Zplugin_classr)r}rr|sr|)Z
__future__rrrr@rqrlrar_�operatorrr4r6rZdnf.loggingrZ
dnf.pycompZdnf.utilZdnf.i18nrZ	getLoggerr8rH�objectrr,rOrNrMrsr|rrrr�<module>s2
2k
%

Zerion Mini Shell 1.0