Current File : //proc/self/root/kunden/lib/python3.9/site-packages/dnf-plugins/__pycache__/repodiff.cpython-39.pyc
a

�&c�,�@sjddlmZddlmZddlZddlmZddlZddlm	Z	Gdd�dej
�ZGdd	�d	ejj
�ZdS)
�)�absolute_import)�unicode_literalsN)�OptionParser)�_cs eZdZdZ�fdd�Z�ZS)�RepoDiff�repodiffcs,tt|��||�|durdS|�t�dS�N)�superr�__init__Zregister_command�RepoDiffCommand)�self�base�cli��	__class__��8/usr/lib/python3.9/site-packages/dnf-plugins/repodiff.pyr
$szRepoDiff.__init__)�__name__�
__module__�__qualname__�namer
�
__classcell__rrrrr src@sLeZdZdZed�Zedd��Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�ZdS)r)rz1List differences between two sets of repositoriesc	Cs�|jddgddtd�d�|jddgdd	td
�d�|jddd
gtjdtd�d�|jdddtd�d�|jddtd�d�|jddtd�d�|jddtd�d�dS)Nz
--repo-oldz-o�append�oldz2Specify old repository, can be used multiple times)�default�action�dest�helpz
--repo-newz-n�newz2Specify new repository, can be used multiple timesz--archz
--archlistz-a�archeszhSpecify architectures to compare, can be used multiple times. By default, only source rpms are compared.z--sizez-s�
store_truez5Output additional data about the size of the changes.)rrz--compare-archzMCompare packages also by arch. By default packages are compared just by name.z--simplez7Output a simple one line message for modified packages.z--downgradezNSplit the data for modified packages between upgraded and downgraded packages.)�add_argumentrrZ_SplitCallback)�parserrrr�
set_argparser/s,
���
����zRepoDiffCommand.set_argparsercCs�|jj}d|_d|_d|_dg|jj_|jj	r6|jj
sJtd�}tj
�|��|jj��D],}|j|jj	|jj
vrz|��qV|��qV|jjs�dg|j_dS)NT�allz*Both old and new repositories must be set.�src)r�demandsZsack_activationZavailable_repos�
changelogsr
ZconfZdisable_excludes�optsrrr�dnf�
exceptions�ErrorZreposr$�id�enable�disabler)rr&�msgZreporrr�	configureMs

zRepoDiffCommand.configurecCs|jjr|j|jfS|jSr)r(�compare_archr�arch)r�pkgrrr�_pkgkey`szRepoDiffCommand._pkgkeyc
s*t�fdd�|D���t����}t�fdd�|D���t����}t�}|j|d�D]&}|j|jd�D]}||��|�<qhqV�jjj}t�fdd�||D��fdd�||D�|ggd�}	|�	|�D]\}
�|
}�|
}|j
|j
kr�q�||j
|j
�d	k�r|	d
�||f�q�|	d�||f�q�|	S)aNcompares packagesets old and new, returns dictionary with packages:
        added: only in new set
        removed: only in old set
        upgraded: in both old and new, new has bigger evr
        downgraded: in both old and new, new has lower evr
        obsoletes: dictionary of which old package is obsoleted by which new
        csg|]}��|�|f�qSr�r4��.0�p�rrr�
<listcomp>m�z-RepoDiffCommand._repodiff.<locals>.<listcomp>csg|]}��|�|f�qSrr5r6r9rrr:or;)�	obsoletes)Zprovidescsg|]}�|�qSrr�r7�k)�new_drrr:zr;csg|]}�|�qSrrr=)�old_drrr:{r;)�added�removedr<�upgraded�
downgradedrrDrC)�dict�set�keys�filterr<r4r
�sack�evr_cmp�intersection�evrr)
rrrZold_keysZnew_keysr<Z	obsoleterZ	obsoletedrJrr>�pkg_old�pkg_newr)r?r@rr�	_repodiffes2
�zRepoDiffCommand._repodiffc
sT�fdd��dd�}��fdd�}tddddd�}t|d	�D],}ttd
���|���|d	|j7<q>t|d�D]Z}ttd���|���|d
���|��}|r�ttd���|���|d|j7<qx�jj	�r�|d�r.ttd��t|d�D],\}}|d|j|j7<|||��q|d�r�ttd��t|d�D],\}}|d|j|j7<|||��qPnX|d|d}	|	�r�ttd��t|	�D],\}}|d|j|j7<|||��q�ttd��ttd��t
|d	���ttd��t
|d����jj	�rXttd��t
|d���ttd��t
|d���n&ttd��t
|d�t
|d����jj�rPttd��||d	���ttd��||d����jj	�s�ttd��||d|d���n4ttd��||d���ttd��||d���ttd��||d	|d|d|d���dS) Ncs �jjrt|�Sd|j|jfS)Nz%s-%s)r(r1�strrrL)r3r9rr�pkgstr�sz'RepoDiffCommand._report.<locals>.pkgstrcSsXt|�}|dkr.|d�tjj�|����7}n&|dkrT|d�tjj�|����7}|S)Nrz ({})z (-{}))rP�formatr)rZ
format_number�strip)Znumr/rrr�sizestr�sz(RepoDiffCommand._report.<locals>.sizestrc
sFg}�jjr*|�d�|��|�f��n
|�d�|�d�|��|�f�|�dt|d��|jrv|jd}nd}|jD]�}|r�|d|dkr��qn6|d|dkr�|d|dkr�|d|dkr��q|�d	|d�d
�tj�|d�tj�|d�f�q��jj	�r4|�t
d��|j	|j	��td�
|��dS)
Nz%s -> %s��-���rZ	timestampZauthor�textz
* %s %s
%sz%a %b %d %YzSize change: {} bytes�
)r(�simpler�lenr'�strftimer)Zi18nZucd�sizerrR�print�join)rMrNZmsgsZ	old_chlogZchlog�rQrrr�report_modified�s:

���


�z0RepoDiffCommand._report.<locals>.report_modifiedr)rArBrCrDrAzAdded package  : {}rBzRemoved package: {}r<zObsoleted by   : {}rCz
Upgraded packagesrDz
Downgraded packagesz
Modified packagesz
SummaryzAdded packages: {}zRemoved packages: {}zUpgraded packages: {}zDowngraded packages: {}zModified packages: {}zSize of added packages: {}zSize of removed packages: {}zSize of modified packages: {}zSize of upgraded packages: {}zSize of downgraded packages: {}zSize change: {})rE�sortedr^rrRr]�getr4r(Z	downgrader[)
rrrTraZsizesr3ZobsoletedbyrMrNZmodifiedrr`r�_report�sr




�


�

�

�
��zRepoDiffCommand._reportcCs�|jj�tj�j|jjd�}|jj�tj�j|jjd�}|jj	rld|jj	vrl|j
|jj	d�|j
|jj	d�|jjr�|j
dd�|j
dd�n|j
dd�|j
dd�|��|��|�
|�||��dS)N)Zreponame�*)r2�)Zlatest_per_arch)Zlatest)r
rI�query�hawkeyZIGNORE_EXCLUDESrHr(rrrZfiltermr1ZapplyrdrO)rZq_newZq_oldrrr�run�s"��zRepoDiffCommand.runN)
rrr�aliasesrZsummary�staticmethodr#r0r4rOrdrirrrrr+s
&ar)Z
__future__rrZdnf.clir)Zdnf.cli.option_parserrrhZdnfpluginscorerZPluginrrZCommandrrrrr�<module>s