Edit File: plugin.cpython-36.opt-1.pyc
3 |TcdV%������������������@���s����d�dl�mZ�d�dl�mZ�d�dl�mZ�d�dlZd�dlZd�dlZd�dlZd�dlZd�dl Z d�dl Z d�dlZd�dlZd�dl Z d�dlZd�dlZd�dlZd�dlmZ�ejd�ZdZG�dd ��d e�ZG�d d��de�Zdd ��Zdd��Zdd��Zdd��Zdd��ZdS�)�����)�absolute_import)�print_function)�unicode_literalsN)�_�dnfzdnf.plugin.dynamicc���������������@���s\���e�Zd�ZdZdZdZedd���Zdd��Zdd ��Z d d��Z dd ��Zdd��Zdd��Z dd��ZdS�)�Pluginz5The base class custom plugins must derive from. #:apiz <invalid>Nc����������������s����t�jj��}|�jr|�jn|�j����fdd�|jD��}xb|D�]Z}tjj|�r6y|j |��W�q6�t k r��}�ztjj td�t|����W�Y�d�d�}~X�q6X�q6W�|S�)Nc����������������s���g�|�]}d�|��f��qS�)z %s/%s.conf��)�.0�path)�namer����/usr/lib/python3.6/plugin.py� <listcomp>9���s����z&Plugin.read_config.<locals>.<listcomp>zParsing file failed: %s)�libdnf�confZConfigParser�config_namer���Zpluginconfpath�osr ����isfile�read� Exceptionr���� exceptionsZConfigErrorr����str)�clsr����parser�files�file�er���)r���r����read_config4���s���� .zPlugin.read_configc�������������C���s���||�_�||�_d�S�)N)�base�cli)�selfr���r���r���r���r����__init__B���s����zPlugin.__init__c�������������C���s���d�S�)Nr���)r���r���r���r���� pre_configG���s����zPlugin.pre_configc�������������C���s���d�S�)Nr���)r���r���r���r����configK���s����z Plugin.configc�������������C���s���d�S�)Nr���)r���r���r���r����resolvedO���s����zPlugin.resolvedc�������������C���s���d�S�)Nr���)r���r���r���r����sackS���s����zPlugin.sackc�������������C���s���d�S�)Nr���)r���r���r���r����pre_transactionW���s����zPlugin.pre_transactionc�������������C���s���d�S�)Nr���)r���r���r���r����transaction[���s����zPlugin.transaction)�__name__� __module__�__qualname__�__doc__r���r����classmethodr���r ���r!���r"���r#���r$���r%���r&���r���r���r���r���r���.���s���r���c���������������@���s~���e�Zd�Zdd��Zdd��Zdd��Zdd��Zd d ��Zdd��Zd d��Z ddd�Z dd��Zdd��Zdd��Z dd��Zdd��Zdd��ZdS�)�Pluginsc�������������C���s���g�|�_�g�|�_d�S�)N)� plugin_cls�plugins)r���r���r���r���r ���a���s����zPlugins.__init__c�������������C���s���|�j����d�S�)N)�_unload)r���r���r���r����__del__e���s����zPlugins.__del__c�������������C���s~���xx|�j�D�]n}yt||����W�q�tjjk r6�����Y�q�tk rt���tj��\}}}tj |||�}t jdj|���Y�qX�qW�d�S�)N��) r.����getattrr���r����Errorr����sys�exc_info� traceback�format_exception�loggerZcritical�join)r����method�plugin�exc_type� exc_value� exc_tracebackZexcept_listr���r���r����_callerh���s����zPlugins._callerc����������������sx���xr|�j�dd��D�]`}|j��t��fdd�|D���r2q|j|�}|jd�o^|jdd�o^|jdd��}|r|�j�j|��qW�dS�)zwChecks whether plugins are enabled or disabled in configuration files and removes disabled plugins from listNc�������������3���s���|�]}t�j���|�V��qd�S�)N)�fnmatch)r ����pattern)r���r���r���� <genexpr>x���s����z)Plugins._check_enabled.<locals>.<genexpr>�mainZenabled)r-���r����anyr���Zhas_sectionZ has_optionZ getboolean�remove)r���r����enable_pluginsZplug_clsr���Zdisabledr���)r���r����_check_enableds���s���� zPlugins._check_enabledc�������������C���s����t�tjkrtd��tjjt���tjt�<�}g�|_t|j ||�}t ||��t��dd��|�_|�j ||��t|�j�dkr�tdd��|�jD���}tjtd�dj|���dS�)z)Dynamically load relevant plugin modules.zload_plugins() called twiceNr���c�������������s���s���|�]}|j�V��qd�S�)N)r���)r ���r;���r���r���r���rB�������s����z Plugins._load.<locals>.<genexpr>zLoaded plugins: %sz, )�DYNAMIC_PACKAGEr4����modules�RuntimeErrorr���Zpycomp� ModuleType�__path__�_get_plugins_filesZ pluginpath�_import_modules�_plugin_classesr-���rG����len�sortedr8����debugr���r9���)r���r���ZskipsrF����packager����namesr���r���r����_load����s���� z Plugins._loadc�������������C���s���|�j�d��d�S�)Nr!���)r?���)r���r���r���r����_run_pre_config����s����zPlugins._run_pre_configc�������������C���s���|�j�d��d�S�)Nr"���)r?���)r���r���r���r����_run_config����s����zPlugins._run_configNc�������������C���s*���x$|�j�D�]}|||�}|�jj|��qW�d�S�)N)r-���r.����append)r���r���r���Zp_clsr;���r���r���r���� _run_init����s���� zPlugins._run_initc�������������C���s���|�j�d��d�S�)Nr$���)r?���)r���r���r���r����run_sack����s����zPlugins.run_sackc�������������C���s���|�j�d��d�S�)Nr#���)r?���)r���r���r���r����run_resolved����s����zPlugins.run_resolvedc�������������C���s���|�j�d��d�S�)Nr%���)r?���)r���r���r���r����run_pre_transaction����s����zPlugins.run_pre_transactionc�������������C���s���|�j�d��d�S�)Nr&���)r?���)r���r���r���r����run_transaction����s����zPlugins.run_transactionc�������������C���s&���t�tjkr"tjtjjd��tjt�=�d�S�)NzPlugins were unloaded.)rH���r4���rI���r8����logr����loggingZDDEBUG)r���r���r���r���r/�������s���� zPlugins._unloadc�������������C���s����|j�s dS�t��}x|�jD�]}||tj|j�<�qW�t|j���}t��}x |j�D�]}|j|j |j ���qJW�|sldS�x|jD�]}|j|j ��qtW�x|D�]}|�jj ||���q�W�dS�)zH Unload plugins that were removed in the `transaction`. N)Z remove_set�dictr.����inspectZgetfile� __class__�set�keys�update�intersectionr���Zinstall_set�difference_updaterE���)r���r&���r.���r;���Zplugin_filesZerased_plugin_filesZpkgZplugin_filer���r���r����unload_removed_plugins����s���� zPlugins.unload_removed_plugins)N)r'���r(���r)���r ���r0���r?���rG���rU���rV���rW���rY���rZ���r[���r\���r]���r/���rh���r���r���r���r���r,���`���s��� r,���c���������������C���s���t�j��S�)N)r����__subclasses__r���r���r���r���rO�������s����rO���c�������������C���s����x�|D�]�}t�jj|�\}}|�jj|��t�jj|�\}}d|�j|f�}ytj|�}W�q�t k r��}�z,t jtd�||��t j tjjddd��W�Y�d�d�}~X�qX�qW�d�S�)Nz%s.%szFailed loading plugin "%s": %sr1���T)r5���)r���r ����splitrL���rX����splitextr'���� importlib� import_moduler���r8����errorr���r^���r���r_���ZSUBDEBUG)rS���Zpy_files�fnr ����moduleZextr���r���r���r���r���rN�������s���� rN���c�������������C���sJ��g�}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�W�d}qdW�|s�x |D�]} t|| �r�|j| ��q�W�| r:|j|��q:W�q&W�|j |�}|�rt jtd�j djt|�����|j |�}|�rFt jtd�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����globr���r ���rk����basename�_plugin_name_matches_pattern�addrX���� differencer8���Zwarningr����formatr9���rQ���)�pathsZdisable_pluginsrF���r.���Zpattern_enable_foundZpattern_disable_found�pro����plugin_nameZdummyZmatchedZenable_pattern_testedZpattern_skipZpattern_enableZenable_not_foundZdisable_not_foundr���r���r���rM�������sD���� rM���c����������������s*���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����-c�������������3���s���|�]}t�j�|���V��qd�S�)N)r@���)r ���r���)rA���r���r���rB�����s����z/_plugin_name_matches_pattern.<locals>.<genexpr>)rc����replacerD���)ry���rA���Z try_namesr���)rA���r���rs�����s���� rs���c����������������s<�����fdd�}t�t��jd��tjf|��jd�d��}|��_��S�)z5A class decorator for automatic command registration.c����������������s���|r|j�����d�S�)N)�register_command)r���r���r���)� command_classr���r���r �����s����z"register_command.<locals>.__init__r���r���)r ���r���)�typer���r'���r���r����aliasesZ_plugin)r}���r ���Zplugin_classr���)r}���r���r|�����s����r|���)Z __future__r���r���r���r@���rq���rl���ra���r_����operatorr���r4���r6���r���Zdnf.loggingr���Z dnf.pycompZdnf.utilZdnf.i18nr���Z getLoggerr8���rH����objectr���r,���rO���rN���rM���rs���r|���r���r���r���r����<module>���s2��� 2k %