AlkantarClanX12

Your IP : 3.147.48.105


Current Path : /lib/python3.6/site-packages/dnf/cli/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/dnf/cli/__pycache__/output.cpython-36.pyc

3

�ft`Z�@s�dZddlmZddlmZddlmZddlZddlZddlZddlZ	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZmZddlmZmZmZmZmZmZmZmZddlmZmZmZm Z m!Z!dd	l"m#Z#dd
l$m%Z%ddl&Z'ddl(Z'ddl)Z'ddl*Z'ddl+Z'ddl,Z'ddlZ'ddl-Z'ddl.Z'ddl/Z'e
j0d�Z1dd
�Z2Gdd�de3�Z4Gdd�de'j5j6�Z7Gdd�de'j5j8�Z9Gdd�de#�Z:ddd�Z;dS)z"Handle actual output from the cli.�)�absolute_import)�print_function)�unicode_literalsN)�
format_number�format_time)�_�C_�P_�ucd�fill_exact_width�
textwrap_fill�exact_width�select_short_long)�xrange�
basestring�long�unicode�sys_maxsize)�TransactionDisplay)�MergedTransactionWrapper�dnfcCsrtj|ftjd��}t|�}|d}||}|s@tjd|�}n|rR|jd|�t|�}tt|f|g|���S)N��)r)�	itertools�chain�repeat�len�extend�iter�list�zip)Z
cols_countZlabel�lst�leftZ
lst_lengthZright_countZ
missing_itemsZlst_iter�r#�/usr/lib/python3.6/output.py�_spread_in_columns6s
r%c@s
eZdZdZdmZejd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Ze
dd��Zedd��Zedd��Zdndd�Ze
dd��Zdd�Zdodd�Zdpd!d"�Zdqd#d$�Zd%d&�Zd'd(�Zd)d*�Zdrd,d-�Zdsd.d/�Zdtd0d1�Zidifd2d3�Zdud4d5�Zd6d7�Z d8d9�Z!d:d;�Z"d<d=�Z#d>d?�Z$d@dA�Z%dvdBdC�Z&dwdDdE�Z'dxdFdG�Z(dHdI�Z)dJdK�Z*dydLdM�Z+dNdO�Z,dPdQ�Z-dRdS�Z.dTdU�Z/dVdW�Z0dzdXdY�Z1d{dZd[�Z2ge3�fd\d]�Z4gfd^d_�Z5e6d`�e6d`�e6da�e6db�e6dc�e6dd�e6de�e6df�e6dg�e6dh�e6di�dj�Z7gfdkdl�Z8dS)|�Outputz+Main output class for the yum command line.� �z	^\*{0,2}/cCs$||_||_tjjj�|_d|_dS)N)�conf�baser�cli�termZTerm�progress)�selfr*r)r#r#r$�__init__IszOutput.__init__cCs0|jj}dd|}|jt||�d�}|||fS)Nz%s�=r')r,�columns�
fmtColumnsr )r.�col_data�rowZ
term_widthZrule�headerr#r#r$�_bannerOszOutput._bannerc	Cszdd�|dD�}xF|D]>}x8t|�D],\}}||}t|�}|j|d�d||<q&WqW|j|ddd�}tttj|��S)NcSsg|]
}t��qSr#)�dict)�.0rr#r#r$�
<listcomp>Vsz&Output._col_widths.<locals>.<listcomp>rrz  )�indent)�	enumerater�get�calcColumnsr�map�operator�neg)	r.�rowsr3r4�i�valZcol_dctZlength�colsr#r#r$�_col_widthsUs
zOutput._col_widthscCs(d}d}|s�n�t|t�s$|dkr2|jjd}n�|dkr<n�x�|jdd�j�D]�}|dkr`d}qN||jjkr~||jj|7}qN||jjkr�||jj|7}qN|jd�r�|dd�|jjkr�||jj|dd�7}qN|jd�o�|dd�|jjkrN||jj|dd�7}qNW|�r |jjd}||fS)	Nr�bold�normal�,r'zfg:r(zbg:)	�
isinstancerr,ZMODE�replace�splitZFG_COLOR�
startswithZBG_COLOR)r.�	highlight�hibeg�hiendZhighr#r#r$�
_highlight`s0

zOutput._highlightcKs$|j|�\}}|jj||||f|�S)N)rPr,�sub)r.ZhaystackrMZneedles�kwdsrNrOr#r#r$�_sub_highlight}szOutput._sub_highlightcCs4d}x*|D]"}||d|kr P||d7}q
W|S)z; Spaces left on the current field will help how many pkgs? rrr#)�currentZ	data_tupsr"�ret�tupr#r#r$�_calc_columns_spaces_helps�s
z!Output._calc_columns_spaces_helpscCs|jjS)N)r*�history)r.r#r#r$rX�szOutput.historycCs|jjS)N)r*�sack)r.r#r#r$rY�szOutput.sackNrrcCs�t|�}|}dg|}x&td|�D]}t||j��||<q"W|dkrN|jj}|dkrndg|d}|jd�|s�g}	xDtd|�D]6}||}
|
r�|	j|
dd�q�|	j||d�q�W|	dt|�7<|jj}t	|	�|kr�|	S|}|t	|�|dt
|�8}|d�s|d7}�x�|dk�r�d}d}
xptd|�D]b}|j|||||�}|�s`�q<|�r�||dk�r�|d|k�r��q<||k�r��q<|}|}
�q<W|�r||
jd�d||
}||
�r�|
|dk�r�|d8}||
|7<||8}�qd}x*td|�D]}||�s"�q|d7}�qW|�rz||}x:td|�D],}||�s\�qJ|||7<||8}�qJW|d8}||}x$td|�D]}|||7<�q�W|||||7<d}�qW|S)a�Dynamically calculate the widths of the columns that the
        fields in data should be placed into for output.

        :param data: a list of dictionaries that represent the data to
           be output.  Each dictionary in the list corresponds to a
           column of output. The keys of the dictionary are the
           lengths of the items to be output, and the value associated
           with a key is the number of items of that length.
        :param columns: a list containing the minimum amount of space
           that must be allocated for each row. This can be used to
           ensure that there is space available in a column if, for
           example, the actual lengths of the items being output
           cannot be given in *data*
        :param remainder_column: number of the column to receive a few
           extra spaces that may remain after other allocation has
           taken place
        :param total_width: the total width of the output.
           self.term.real_columns is used by default
        :param indent: string that will be prefixed to a line of
           output to create e.g. an indent
        :return: a list of the widths of the columns that the fields
           in data should be placed into for output
        Nrr����r[)
r�range�sorted�itemsr,�real_columns�appendrr1�sumr
rW�pop)r.�datar1�remainder_column�total_widthr:rDZpdata�dZfull_columns�colZ
default_widthZhelpsrCZthelps�diffZoverflowed_columnsZnormr#r#r$r=�s�



"




zOutput.calcColumnscCs|dkrd|fSd|fS)z$Returns tuple of (align_left, width)rTFr#)�widthr#r#r$�_fmt_column_align_widths
zOutput._fmt_column_align_widthcCslt|�dkst|�dkst�t|�dkr8|\}}d}}t|�dkr\|\}}}|j|�\}}t|�|||fS)NrZr(r)r�AssertionErrorrPr
)r.r3rCrirNrOrMr#r#r$�	_col_datas
zOutput._col_datac
CsFt|�}t|�}g}x�|dd	�D]�}|j|�\}}}	}
|sP|d7}|j|�q"|j|�\}}t|�}||kr�|d7}|r�|j|	|d|||
g�q�|j|	d||||
g�n(|dd||d7}|j|	||
g�||7}|d7}q"W|j|d
�\}}}	}
|j|�\}}t||||	|
d�}|d|7}|j|�|t|�S)a.Return a row of data formatted into a string for output.
        Items can overflow their columns.

        :param columns: a list of tuples containing the data to
           output.  Each tuple contains first the item to be output,
           then the amount of space allocated for the column, and then
           optionally a type of highlighting for the item
        :param msg: a string to begin the line of output with
        :param end: a string to end the line of output with
        :return: a row of data formatted into a string for output
        Nrz%sz	%s%s%s%s r'z%s%s%s
)r"�prefix�suffixz%%s%sr[r[)	rrrlr`rjr
rr�tuple)
r.r1�msg�endrercr3rCrirNrOZ
align_leftZ	val_widthr#r#r$r2%s6


zOutput.fmtColumnsFcCsP|dkrd
}d||j|jf}|ddg}t||j|jf||�}t|j|��dS)a�Print a package as a line.

        :param pkg: the package to be printed
        :param ui_overflow: unused
        :param indent: string to be prefixed onto the line to provide
           e.g. an indent
        :param highlight: highlighting options for the name of the
           package
        :param columns: tuple containing the space allocated for each
           column of output.  The columns are the package name, version,
           and repository
        N�(��z%s%s.%srG���������)rurvrw)�name�archr �evr�
_from_repo�printr2)r.�pkg�ui_overflowr:rMr1Zna�hi_colsr#r#r$�
simpleListTs
zOutput.simpleListc	CsN|dkrd}d|t|�f}|ddg}|j}t||f||�}t|j|��dS)	a(Print a package as a line, with the package itself in envra
        format so it can be passed to list/install/etc.

        :param pkg: the package to be printed
        :param ui_overflow: unused
        :param indent: string to be prefixed onto the line to provide
           e.g. an indent
        :param highlight: highlighting options for the name of the
           package
        :param columns: tuple containing the space allocated for each
           column of output.  The columns the are the package envra and
           repository
        N�?rtz%s%srG�����)r�r�)r
�ui_from_repor r|r2)	r.r}r~r:rMr1ZenvrarZridr#r#r$�simpleEnvraListjs
zOutput.simpleEnvraListcCstt|j��dS)z.Print a package as a line containing its name.N)r|r
rx)r.r}r#r#r$�simple_name_list�szOutput.simple_name_listcCstt|��dS)z/Print a package as a line containing its NEVRA.N)r|r
)r.r}r#r#r$�simple_nevra_list�szOutput.simple_nevra_listcCs�t|�}|jj}|st}n|dkr&d}d|dd}|s>|St|�}t||||d�}|jd�dkr�||dkr�t|||d	d�}|S)
z�Return a key value pair in the common two column output
        format.

        :param key: the key to be formatted
        :param val: the value associated with *key*
        :return: the key value pair formatted in two columns for output
        �r'rZz: )riZinitial_indentZsubsequent_indent�
rr(z
     ...: )r
r,r_rr
r�count)r.�keyrCZkeylenrDZnxtrUr#r#r$�
fmtKeyValFill�s zOutput.fmtKeyValFillr0cCsht|�}|jjd}t|�}||dkr6|d}}n$|||d}|||t|�}d|||fS)a�Format and return a section header.  The format of the
        header is a line with *name* centered, and *fill* repeated on
        either side to fill an entire line on the terminal.

        :param name: the name of the section
        :param fill: the character to repeat on either side of *name*
          to fill an entire line.  *fill* must be a single character.
        :return: a string formatted to be a section header
        rZ�z%s %s %s)r
r,r1r
r)r.rxZfillrDZname_lenZbegrqr#r#r$�
fmtSection�s
zOutput.fmtSectioncs�dd�}�fdd�}g}�j|�\}}tdtdd�tdd��}|j||d	||j|f��|jrv|j|td
�|j��tdtdd�tdd��}|j|||j��|j|td�|j��tdtdd
�tdd��}|j|||j	��tdtdd�tdd��}|j||t
t|j����|j|td�|j
��tdtdd�tdd��}|j|||j��|j�r��jj|�}	|	�r�|j|td�|	���jj�r>|j|td�|j��|j|td�tjj|j���|j�r�|j|td�tjj|j����jj|�}
|
�r>yt|
jj��}Wntk
�r"d}YnX|j|td��j|���tdtdd�tdd��}|j|||j ��|j!�r�|j|td�t"|j!���|j|td�|j#��tdtdd�tdd��}|j|||j$��dj%|�S)z�Print information about the given package.

        :param pkg: the package to print information about
        :param highlight: highlighting options for the name of the
           package
        cSsdjt|dd�dt|�g�S)Nr'��:)�joinr�str)r�rCr#r#r$�format_key_val�sz)Output.infoOutput.<locals>.format_key_valcs�jt|dd�d|pd�S)Nr�z : r)r�r)r�rC)r.r#r$�format_key_val_fill�sz.Output.infoOutput.<locals>.format_key_val_fillr��short�Namerz%s%s%sZEpoch�VersionZRelease�Arch�Architecture�SizeZSource�Repo�
Repositoryz	From repoZPackagerZ	BuildtimezInstall timeNzInstalled byZSummaryZURLZLicenseZDescriptionr�)&rPrrr`rxZepochr�version�releaseryr�float�_sizeZ	sourcerpm�repoid�_from_systemrXZrepor)�verboseZpackagerr�utilZnormalize_timeZ	buildtimeZinstalltimeZpackage_data�int�_itemZgetInstalledBy�
ValueError�_pwd_ui_username�summary�urlr
�license�descriptionr�)r.r}rMr�r�Zoutput_listrNrOr�Zhistory_repoZhistory_pkg�uidr#)r.r$�
infoOutput�sh

zOutput.infoOutputc
Cs�|\}}|dk	rV|jj}|jtjkr,|jj}|j|||d�|j||d|jjd�dS|j�}d|j	|j
f}|j}	td||	||f�dS)	a{Print a simple string that explains the relationship
        between the members of an update or obsoletes tuple.

        :param uotup: an update or obsoletes tuple.  The first member
           is the new package, and the second member is the old
           package
        :param changetype: a string indicating what the change between
           the packages is, e.g. 'updates' or 'obsoletes'
        :param columns: a tuple containing information about how to
           format the columns of output.  The absolute value of each
           number in the tuple indicates how much space has been
           allocated for the corresponding column.  If the number is
           negative, the text in the column will be left justified,
           and if it is positive, the text will be right justified.
           The columns of output are the package name, version, and repository
        N)r1rMr'r�)r1r:rMz%s.%sz%-35.35s [%.12s] %.10s %-20.20sz    )
r)�color_update_remote�reponame�hawkeyZSYSTEM_REPO_NAME�color_update_localr��color_update_installedZcompactPrintrxryr�r|)
r.ZuotupZ
changetyper1Z	changePkgZinstPkgZchiZ	c_compactZ	i_compactZc_repor#r#r$�updatesObsoletesLists
zOutput.updatesObsoletesListcCsl|dk�rht|�dk�r`td|�t�}|dkrbi}x"|D]}	|	|t|	�t|	j�<q<W|j�}x�t|�D]�}	|	j|	jf}
d}|
|kr�|j	dd	�}nD|	j
||
�r�|j	d
d	�}n(|	j||
�r�|j	dd�}n|j	d
d	�}|dkr�|j|	d||d�ql|dk�r|j
|j|	|d�d�ql|dk�r0|j|	�ql|dkrl|j|	�qlqlW|�r`tdjt|���t|�SdS)a�Prints information about the given list of packages.

        :param lst: a list of packages to print information about
        :param description: string describing what the list of
           packages contains, e.g. 'Available Packages'
        :param outputType: The type of information to be printed.
           Current options::

              'list' - simple pkg list
              'info' - similar to rpm -qi output
              'name' - simple name list
              'nevra' - simple nevra list
        :param highlight_na: a dictionary containing information about
              packages that should be highlighted in the output.  The
              dictionary keys are (name, arch) tuples for the package,
              and the associated values are the package objects
              themselves.
        :param columns: a tuple containing information about how to
           format the columns of output.  The absolute value of each
           number in the tuple indicates how much space has been
           allocated for the corresponding column.  If the number is
           negative, the text in the column will be left justified,
           and if it is positive, the text will be right justified.
           The columns of output are the package name, version, and
           repository
        :param highlight_modes: dictionary containing information
              about to highlight the packages in *highlight_na*.
              *highlight_modes* should contain the following keys::

                 'not_in' - highlighting used for packages not in *highlight_na*
                 '=' - highlighting used when the package versions are equal
                 '<' - highlighting used when the package has a lower version
                       number
                 '>' - highlighting used when the package has a higher version
                       number
        :return: number of packages listed
        r�inforx�nevrarz%sFznot inrGr0�>rF�<T)r~rMr1)rMr�N)rr�rxr�)rr|�setr�r{�valuesr]rxryr<Zevr_eqZevr_ltr��addr�r�r�r�)r.r!r�Z
outputTypeZhighlight_nar1Zhighlight_modesZinfo_setZunique_item_dictr}r�rMr#r#r$�listPkgs3s@'



zOutput.listPkgscCs2ttd��ttd��f}ttd��ttd��f}||}x�|dkrJtd�}d}|jjrl|dkrhtd�}n|}ytjj|�}Wn.tk
r�Yntk
r�|d	}YnXt|�j	�}t
|�d	kr�|jjr�|d	n|d	}||kr�Pd|ko�d|k�r|d	}Pd|kr:d|kr:|d	}Pq:W||k�r.d
SdS)z�Get a yes or no from the user, and default to No

        :msg: String for case with [y/N]
        :defaultyes_msg: String for case with [Y/n]
        :return: True if the user selects yes, and False if the user
           selects no
        �y�yes�n�noNzIs this ok [y/N]: rzIs this ok [Y/n]: rTF)r
rr)Z
defaultyesrZi18nZ	ucd_input�EOFError�KeyboardInterrupt�lowerr)r.rpZdefaultyes_msgZyuiZnuiZauiZchoicer#r#r$�userconfirm�s>

zOutput.userconfirmcCs~|jj�j�j�}|jj�j�j�}i}xPtjtt|��d�D]6}||kr^||d||<q@||kr@||d||<q@W|S)Nrr)	rY�query�	installedZ
_name_dict�	availablerrrr )r.�sectionsr�r�rf�pkg_namer#r#r$�_pkgs2name_dict�szOutput._pkgs2name_dictc	Cs�i}i}x~tjtt|��d�D]d}|j|�}|dkr8q tt|��t|j�}tt|j��}|j|d�d||<|j|d�d||<q W||fS)Nrr)	rrrr r<r
r
�GRP_PACKAGE_INDENTr�)	r.r��	name_dictZ
nevra_lengthsZrepo_lengthsr�r}Znevra_lZrepo_lr#r#r$�_pkgs2col_lengths�s
zOutput._pkgs2col_lengthscCs$x|D]}td|j|f�qWdS)Nz%s%s)r|r�)r.�	pkg_namesrxr#r#r$�_display_packages�s
zOutput._display_packagescCspxj|D]b}y||}Wn(tk
r>td|j|f�wYnXd}|jsR|jj}|j|d|j||d�qWdS)Nz%s%sFT)r~r:rMr1)�KeyErrorr|r�r�r)Zcolor_list_available_installr�)r.r�r�r1rxr}rMr#r#r$�_display_packages_verbose�s
z Output._display_packages_verbosec
Csldd�}tdtd�|j�|jj}|r@ttd�t|j��|jr`ttd�t|j�p\d�|jrxttd�|j�td	�||j	�ftd
�||j
�ftd�||j�ftd�||j�ff}|�r0|j
|�}|j||�}|j|�}|d
|df}xp|D].\}}	t|	�dk�rq�t|�|j|	||�q�Wn8x6|D].\}}	t|	�dk�rP�q6t|�|j|	��q6WdS)z�Output information about the packages in a given group

        :param group: a Group object to output information about
        cSstdd�|D��S)Ncss|]}|jVqdS)N)rx)r8r}r#r#r$�	<genexpr>�sz?Output.display_pkgs_in_groups.<locals>.names.<locals>.<genexpr>)r])�packagesr#r#r$�names�sz,Output.display_pkgs_in_groups.<locals>.namesr�z	Group: %sz
 Group-Id: %sz Description: %srz
 Language: %sz Mandatory Packages:z Default Packages:z Optional Packages:z Conditional Packages:rrN)r|r�ui_namer)r�r
�id�ui_descriptionZ	lang_onlyZmandatory_packagesZdefault_packagesZoptional_packagesZconditional_packagesr�r�r=rr�r�)
r.�groupr�r�r�r�Zcol_lengthsr1�section_namer�r#r#r$�display_pkgs_in_groups�s8

zOutput.display_pkgs_in_groupscCs�dd�}ttd�|j�|jjr8ttd�t|j��|jr\t|j�pJd}ttd�|�td�||j�ftd�||j	�ff}x0|D](\}}t
|�d	kr�q�t|�|j|�q�Wd
S)z�Output information about the packages in a given environment

        :param environment: an Environment object to output information about
        cSstdd�|D��S)Ncss|]}|jVqdS)N)rx)r8r�r#r#r$r�	szFOutput.display_groups_in_environment.<locals>.names.<locals>.<genexpr>)r])�groupsr#r#r$r�sz3Output.display_groups_in_environment.<locals>.nameszEnvironment Group: %sz Environment-Id: %srz Description: %sz Mandatory Groups:z Optional Groups:rN)r|rr�r)r�r
r�r�Zmandatory_groupsZoptional_groupsrr�)r.Zenvironmentr�r�r�r�r�r#r#r$�display_groups_in_environmentsz$Output.display_groups_in_environmentcsVd���fdd�	����fdd�}�jjr4d�}nd�j�jf}�j|�jpRd�}�r|�d	krj�jj��j|��d
d�}t|�|d	kr��jj	}|s�d	Stt
d��j�d}d}	�xXt|�D�]J}
�j|
kr�d
}	qˆj
|
k�rt
d
�}�||
|d
d�d
}qˆj|
k�r,t
d�}�||
|dd�d
}qˆj|
k�rVt
d�}�||
|dd�d
}q�||
|��rhd
}q�t
d�}x��jD]�}t|�}tj||
��r��|||dd�d
}n`|j�d}
td��t�fdd�|
D���r�|
j�d}n|
}tj|
|��rx�|||dd�d
}�qxWq�Wt||	g��sLx*t|�D]}
t
d�}�||
|dd��q*Wt�d	S)a�Output search/provides type callback matches.

        :param po: the package object that matched the search
        :param values: the information associated with *po* that
           matched the search
        :param matchfor: a list of strings to be highlighted in the
           output
        :param verbose: whether to output extra verbose information
        :param highlight: highlighting options for the highlighted matches
        Fcsd|sttd��t|�pd}|dkr(dS�r>�j|��dd�}|rTt�j||��nt||�dS)Nz
Matched from:rT)�ignore_case)r|rr
rSr�)r��itemZprinted_headline�can_overflow)rM�matchforr.r#r$�print_highlighted_key_item'sz8Output.matchcallback.<locals>.print_highlighted_key_itemcsT�jj|�sdStd�}d}x2�jD](}tj||�r$�|||p@|dd�d}q$W|S)NFzFilename    : %s)r�T)�FILE_PROVIDE_RE�matchr�files�fnmatch)r��
printed_matchr�Z
file_match�filename)�por�r.r#r$�print_file_provides4sz1Output.matchcallback.<locals>.print_file_providesz%s : z%s.%s : rNT)r�zRepo        : %szDescription : )r�zURL         : %szLicense     : %szProvide    : %srz=<>c3s|]}|�kVqdS)Nr#)r8�char)�possibler#r$r�psz'Output.matchcallback.<locals>.<genexpr>zOther       : %s)F)r)Zshowdupesfromreposrxryr�r�Zcolor_search_matchrSr|r�rr�r�r�r�r�Zprovidesr�r�rK�any)r.r�r�r�r�rMr�rpr�Z
name_matchr�r�ZprovideZ
first_provideZitem_newr#)rMr�r�r�r�r.r$�
matchcallbacksp


zOutput.matchcallbackcCs|j|||dd�S)aqOutput search/provides type callback matches.  This will
        output more information than :func:`matchcallback`.

        :param po: the package object that matched the search
        :param values: the information associated with *po* that
           matched the search
        :param matchfor: a list of strings to be highlighted in the
           output
        T)r�)r�)r.r�r�r�r#r#r$�matchcallback_verboses
zOutput.matchcallback_verbosec
Csd}d}d}d}x�|D]�}yrt|j�}||7}y|j�r@||7}Wntk
rVYnX|s^wyt|j�}Wntk
r�YnX||7}Wqtk
r�d}td�}	tj|	�PYqXqW|�s|r�tjtd�t	|��||k�r�tjtd�t	||��|�rtjtd�t	|��dS)	z�Report the total download size for a set of packages

        :param packages: a list of package objects
        :param installonly: whether the transaction consists only of installations
        rFTz2There was an error calculating total download sizezTotal size: %szTotal download size: %szInstalled size: %sN)
r�r�ZverifyLocalPkg�	ExceptionZinstallsizer�logger�errorr�r)
r.r�Zinstallonly�totsizeZlocsizeZinsizer�r}�sizerpr#r#r$�reportDownloadSize�sD






zOutput.reportDownloadSizecCsrd}d}xL|D]D}y|j}||7}Wqtk
rPd}td�}tj|�PYqXqW|sntjtd�t|��dS)zmReport the total size of packages being removed.

        :param packages: a list of package objects
        rFTz-There was an error calculating installed sizezFreed space: %sN)r�r�rr�r�r�r)r.r�r�r�r}r�rpr#r#r$�reportRemoveSize�s

zOutput.reportRemoveSizecCs*|sdSg}g}|jr$|jtd��xJ|jD]@}t|j|��}|j|�}|rR|jn|}	|jtdd|	|��q,W|j	r�|jtd��x@|j	D]6}t|j
|��}|jj|�j}	|jtdd|	|��q�W|�r |j
|�}
x$|D]}|j|jt||
�d��q�W|j|
td�td�ddf�|d	d	�<d
j|�S)Nz+Marking packages as installed by the group:r��@z)Marking packages as removed by the group:r'ZGroup�Packagesrrr�)Z
new_groupsr`rrZadded_packagesZ_group_by_idr�rr%Zremoved_groupsZremoved_packagesr�r<rEr2r r6r�)r.�compsrXrh�outrAZgrp_idZpkgsZgroup_objectZgrp_namer3r4r#r#r$�list_group_transaction�s.


$zOutput.list_group_transactioncQs�tjtjBtjBtjBtjBtjB}t�}t�}|dkr<g}tj	j
|�}g}iiid�}d}	gf�fdd�	}
tjjr|t
d�nt
d�}�xPtdd	�|jftdd
�|jftdd�|jf||jft
d�|jft
d
�|jft
d�|jft
d�|jft
d�|jftdd�|jfg
D]�\}}
g}i}xL|D]D}|jtjjk�r6�qx(|jj�D]}|j|t��j |��qBW�qWx\t!|
dd�d�D]H}|jtjj"tjj#gk�r��qxt!|j$|jg��}|
|||	|j%|�}	�qxW|j&||f��qWt!t'�jj(j)��j*��}|�rXt
d�}g}xF|D]>\}}x2t+|�D]&}|j&d||fddddddf��qW�qW|j&||f�t!t'�jj(j,��j*��}|�r�t
d�}g}xF|D]>\}}x2t+|�D]&}|j&d||fddddddf��q�W�q�W|j&||f�t!t'�jj(j-��j*��}|�r<t
d�}g}x*|D]"\}}|j&|d|ddddf��qW|j&||f�t!t'�jj(j.��j*��}|�r�t
d�}g}x:|D]2\}}|j&|dd|d|dfddddf��qlW|j&||f�t!t+�jj(j/���}|�rt
d�}g}x&|D]}|j&|ddddddf��q�W|j&||f�t!t+�jj(j0���}|�rht
d�}g}x&|D]}|j&|ddddddf��q8W|j&||f��jj1�rNdd �}�jj1j2j3}|�r�t
d!�}g}x |j4�D]}|j&||���q�W|j&||f��jj1j2j5} | �rt
d"�}g}x | j4�D]}|j&||���q�W|j&||f��jj1j2j6}!|!�rdt
d#�}g}x |!j4�D]}|j&||���q>W|j&||f��jj1j7j3}"|"�r�t
d$�}g}x |"j4�D]}|j&||���q�W|j&||f��jj1j7j5}#|#�rt
d%�}g}x |#j4�D]}|j&||���q�W|j&||f��jj1j7j6}$|$�rNt
d&�}g}x |$j4�D]}|j&||���q(W|j&||f��j8j9�rv�jj:j;|@�rvg}�jj<d'|d(�\}}t'd)d*�|D��}x"t!|�D]}%|
|||	|%g�}	�q�Wd+g}&�jj=�s�|&j&d,�t
d-�d.j>|&�}'d/d0�|D�}|j&|'|f�g}x*t!|j*��D]\}(}%|
|||	|%g�}	�qWt
d1�}'�jj8j?�rN|'d}'n|'t
d2�}'d3d0�|D�}|j&|'|f��j@jA})|d4�rˆjj(jB��rˆjj1�o��jj1j7�p��jj1j2�r�dS|d4i|d5|d6ig}d|	ddd7g}*�jC|d8|*d9|d:�}*|*\}+}	},}-}.tD|*�d7}/|)|/k�r&|)n|/})tE|+td;d<�td=d<��}0tE|	td;d>�td=d?��}1tE|,td;d@�td=d@��}2tE|-td;dA�td=dB��}3tE|.td;dC�td=dC��}4dDdE|)�jF|0|+f|1|	f|2|,f|3|-f|4|.ffd.�dE|)fg}5x�|D]�\}}|�	rdF|}6x�|D]�\}7}8}9}:};}<}=|7|+|=f|8|	f|9|,f|:|-f|;|.ff}*�jF|*d.dG�}>�jG�j8jH�\}?}@xBt!|<�D]6}AdHt
dI�dJ}B|B|?|AjI|@|AjJ|AjKf;}B|>|B7}>�	qrW|6|>}6�	q
W|�r�|5j&|6��q�W|5j&t
dK�dE|)�t
dL�tL|j�tL|j�tL|j�tL|j�dft
dM�tL|j�dft
dN�tL|j�tL|j�tL|j�dft
dO�tL|j�dft
dP�tL|�tL|�dff}Cd}Dd}Ed}Fd}Gx�|CD]�\}}H}I|H�
r�|I�
r��
q�tMd<dQ|H�}JtN|�}KtNtO|H��}LtN|J�}M|I�
r�tNtO|I��}Nnd}NtP|K|D�}DtP|L|E�}EtP|M|F�}FtP|N|G�}G�
q�Wx�|CD]�\}}H}ItMd<dQ|H�}J|I�r�tMdRdS|I�}OtQ||D�}P|H�r�dT}>|5j&|>|P|E|HdU|F|Jf|G|I|Of�n$dV}>|5j&|>|P|E|Fd.|G|I|Of�n&|H�r$dW}>|5j&|>tQ||D�|E|H|Jf��q$Wdj>|5�S)Xz]Return a string representation of the transaction in an
        easy-to-read format.
        N)r��v�rrcs�|j\}}}}}	|j}
|j}t|j�}|dkr2d}|jrB�jj}
n|jrR�jj	}
n�jj
}
|j|||
||||
f�xRdt|�fdt|
�fdt|�ffD],\}}||j
|d�|||d7<q�Wt|t|��}|S)NZnoarchr�r�r�rr)Zpkgtuprzr{rr�r�r)r�Z
_from_cmdliner�r�r`r�
setdefault�max)�linesrc�a_widr��	obsoletesr��a�er�r�rzr�r��hirf)r.r#r$�	_add_line�s"


,z*Output.list_transaction.<locals>._add_linez Installing group/module packageszInstalling group packagesr�Z
InstallingZ	UpgradingZReinstallingzInstalling dependencieszInstalling weak dependenciesZRemovingzRemoving dependent packageszRemoving unused dependenciesZDowngradingcSs|jS)N)r})�xr#r#r$�<lambda>4sz)Output.list_transaction.<locals>.<lambda>)r�zInstalling module profilesz%s/%srzDisabling module profileszEnabling module streamszSwitching module streamsz%s -> %srzDisabling moduleszResetting modulescSs&|j�}|r|ntd�ddddddfS)Nz<name-unset>r)ZgetNamer)r�rxr#r#r$�format_lineqsz,Output.list_transaction.<locals>.format_linezInstalling Environment GroupszUpgrading Environment GroupszRemoving Environment GroupszInstalling GroupszUpgrading GroupszRemoving GroupsT)Zreport_problems�transactioncss|]}t|�|fVqdS)N)r�)r8r}r#r#r$r��sz*Output.list_transaction.<locals>.<genexpr>z--bestz--allowerasingzSSkipping packages with conflicts:
(add '%s' to command line to force their upgrade)r'cSsg|]}|dd�d�qS)Nrrr[)rr#)r8rBr#r#r$r9�sz+Output.list_transaction.<locals>.<listcomp>z,Skipping packages with broken dependencies%sz or part of a groupcSsg|]}|dd�d�qS)Nrrr[)rr#)r8rBr#r#r$r9�sr�r�r��z  rZ)r:r1rdrer�ZPackagerr�r�r�r�r�r�z	%s
%s
%s
r0z%s:
r�z     Z	replacingz  %s%s%s.%s %s
z
Transaction Summary
%s
�Install�UpgradeZRemove�	DowngradeZSkipr�zDependent packagezDependent packagesz%s  %*d %s (+%*d %s)
z%-*sz%s  %s  ( %*d %s)
z%s  %*d %s
)Rr�ZUPGRADEZUPGRADE_ALLZDISTUPGRADEZDISTUPGRADE_ALLZ	DOWNGRADE�INSTALLr�rr�Z_make_listsr*ZWITH_MODULESrrr�ZupgradedZreinstalledZinstalled_groupZ
installed_depZinstalled_weakZerasedZ
erased_depZerased_cleanZ
downgraded�action�libdnfr	ZTransactionItemAction_OBSOLETEDr�Z
getReplacedByr�r�r]ZFORWARD_ACTIONSZTransactionItemAction_REMOVEr<r}r`r7Z_moduleContainerZgetInstalledProfilesr^rZgetRemovedProfilesZgetEnabledStreamsZgetSwitchedStreamsZgetDisabledModulesZgetResetModulesZ_history�envZ
_installedr�Z	_upgradedZ_removedr�r)ZbestZ_goal�actionsZ_skipped_packagesZ_allow_erasingr�Zupgrade_group_objects_upgrader,r1Z	isChangedr=rarr2rPr�rxryrzrr	r
rr�r)Qr.r	reZforward_actionsZskipped_conflictsZskipped_brokenZ
list_bunchZ
pkglist_linesrcrrZ
ins_group_msgrZpkglistr�Zreplaces�tsirBZ	obsoletedZinstalledProfilesrxZprofilesZprofileZremovedProfilesZenabledStreams�streamZswitchedStreamsZdisabledModulesZresetModulesrZinstall_env_groupr�Zupgrade_env_groupZremove_env_groupZ
install_groupZ
upgrade_groupZremove_groupr}ZrecommendationsZskip_strr�Zoutput_widthr1Zn_widZv_widZr_widZs_widZ
real_widthZmsg_packageZmsg_archZmsg_versionZmsg_repositoryZmsg_sizer�Ztotalmsgr�rrzr�r�rrrprNrOZobspoZappendedZsummary_dataZmax_msg_actionZ
max_msg_countZmax_msg_pkgsZmax_msg_depcountr�ZdepcountZmsg_pkgsZlen_msg_actionZ
len_msg_countZlen_msg_pkgsZlen_msg_depcountZmsg_deppkgsZ
action_msgr#)r.r$�list_transaction�s�$
 ,,.





$







zOutput.list_transactionc
s��fdd�}|sdSg}g}|jdj|��x|D]}|jt|��q2Wxd
D]}|||�}|rNPqNW|sz�jjdg}xD|r�|dt|��}	|jdj�jt|	|����|t|�d�}q|W|S)Ncs�t|�|krgS�jj|dd}|dkr0gSdg|}d}x`|D]X}t|�||kr�t|�||}||krtgS||8}t|�||<|d7}|t|�;}qDWx8tt|��D](}||||7<||d9<q�W|S)zb Work out how many columns we can use to display stuff, in
                the post trans output. rrZrr[)rr,r1r\)�msgs�numr"Zcol_lensrgrprh)r.r#r$�
_fits_in_colsKs(

z+Output._pto_callback.<locals>._fits_in_colsrz{}:���r
r�r(rZz  {})rrrr
r�r(rZ)r`�formatr�r,r1rr2r )
r.rZtsisrr�rrrrDZcurrent_msgsr#)r.r$�
_pto_callbackHs&


zOutput._pto_callbackcCstjj|j||j�S)z{
        Return a human-readable summary of the transaction. Packages in sections
        are arranged to columns.
        )rr�Z_post_transaction_outputr*r)r.r	r#r#r$�post_transaction_outputzszOutput.post_transaction_outputcCs@d}|jjdkr6tjjjtjd�}tjjjtjd�|_|t�fS)z_Set up the progress callbacks and various
           output bars based on debug level.
        NrZ)Zfo)	r)Z
debuglevelrr+r-ZMultiFileProgressMeter�sys�stdout�DepSolveProgressCallBack)r.�progressbarr#r#r$�setup_progress_callbacks�s
zOutput.setup_progress_callbackscCsz|dkrdS|jj}tjd|�tdtj�|�}dt||�t|�t|�f}tt	d�|t
|��|}tj|�dS)a!Outputs summary information about the download process.

        :param remote_size: the total amount of information that was
           downloaded, in bytes
        :param download_start_timestamp: the time when the download
           process started, in seconds since the epoch
        rN�-g{�G�z�?z %5sB/s | %5sB %9s     ZTotal)r,r1r�r�r��timerrrrr)r.Zremote_sizeZdownload_start_timestampriZdl_timerpr#r#r$�download_callback_total_cb�s
z!Output.download_callback_total_cbcCs�t�}t�}d}xD|D]<}|jtjjtjjfkr2q|j|j�|j|j�|d7}qWt	|�dkrt|dj
t|��fS|dj
t|��fS)Nrrz, r)
r�rrr	ZTransactionItemAction_UPGRADEDZ TransactionItemAction_DOWNGRADEDr��action_nameZaction_shortrr�r]r)r.ZhpkgsrZ
actions_shortr�r}r#r#r$�_history_uiactions�s
zOutput._history_uiactionsc	st|t�r��fdd�|D�S|dks.|dkrftd�}td�d|}�dk	r^t|��kr^|}t|�Sdd	�}yrtjt|��}|t|j�d
d�}t|j	�}d||f}�dk	r�t|��kr�d
||�|f}t|��kr�d|}|St
k
�r�t|�SXdS)Ncsg|]}�j|���qSr#)r�)r8�u)�limitr.r#r$r9�sz+Output._pwd_ui_username.<locals>.<listcomp>�����z<unset>ZSystemr'cWs|j|�}|sdS|dS)zf Split gives us a [0] for everything _but_ '', this function
                returns '' in that case. rr)rK)�text�argsrUr#r#r$�
_safe_split_0�s
z.Output._pwd_ui_username.<locals>._safe_split_0�;rZz%s <%s>z%s ... <%s>z<%s>)r+r,)rIrrrr
�pwd�getpwuidr�Zpw_gecosZpw_namer�)	r.r�r*Zloginidrxr/�user�fullnameZ	user_namer#)r*r.r$r��s*

zOutput._pwd_ui_usernamec
Csz|jj|�}|jjdkr"ddg}nf|jjdkr6dg}nR|jjdksFt�t�}d}d}x2|D]*}|d7}|jdkrx|d7}|j|j�qZWd}t	|�dkr�t
d	�}	|jj}
|
dkr�t
jjjd�}
|
dkr�d
}
|
dkr�|
dnd
}nt
d
�}	d
}t|tt
d�dd�t|	||�tt
d�dd�tt
d�dd�tt
d�dd�f�d#|dddddd}td|�d}|dk�r|t|�}x�|D]�}t	|�dk�r�|j�p�d}	n|j|jd
�}	t|	�}	tjdtj|j��}
|j|j��\}}t|	||�}	t|dd�}d}}|jdk�rd}}n"|j�r&d}}n|j�r6d}}|j�rBd }|j�rNd!}t||j|	|
||fd"||f��q�WdS)$z�Output a list of information about the history of yum
        transactions.

        :param tids: transaction Ids; lists all transactions if empty
        ZusersrrZZcommandszsingle-user-commandsrNz%s | %s | %s | %s | %szCommand line��O�7z	User nameZIDrz
Date and timertz	Action(s)�ZAlteredrr(r$z%6u | %s | %-16.16s | %s | %4uTrz%Y-%m-%d %H:%Mr'�*�#�Er�r�z%s%s�	) rX�oldr)Zhistory_list_viewrkr��cmdliner��loginuidrrr,r_rr+Z_real_term_widthr|r�reversedr�r
r%�strftime�	localtime�
beg_timestampr(rc�return_codeZ	is_output�altered_lt_rpmdb�altered_gt_rpmdb�tid)r.�tids�reverse�transactionsZuids�doneZblanksr	�fmtrxZ	real_colsZ
name_widthZtable_widthZtmrZuiactsZrmarkZlmarkr#r#r$�historyListCmd�sr



 



zOutput.historyListCmdcCst|�}|jj�}|dkr8tjtd��tjjtd���|j	}|j
}g}|sz|jjdd�}|dk	r�|j|j	�|j|�n|jj
|�}|s�tjtd��tjjtd���d
\}}	d}
d}|r�t|�}|j�\}}	�x|D]�}|dk	o�|j	|k�r|jj�}
|jt|
��d}d}|j	|k�rL|j	|	k�rL|
dk�r<t|�}
n
|
j|�d}n`|
dk	�r�|�rhtd	d
�d}|j|
�d}
|�r�|j�\}}	|j	|k�r�|j	|	k�r�|}
d}|s�|�r�td	d
�d}|j||�q�W|
dk	�r�|�r�td	d
�|j|
�dS)z�Output information about a transaction in history

        :param tids: transaction Ids; prints info for the last transaction if empty
        :raises dnf.exceptions.Error in case no transactions were found
        NzNo transactionszFailed history infoF)Zcomplete_transactions_onlyz$No transaction ID, or package, givenrTr$r6r[r[)r[r[)r�rX�lastr��criticalrr�
exceptions�ErrorrG�end_rpmdb_versionr�r`r=r]rbrYZ_rpmdb_versionZcompare_rpmdbvr�r�merger|�_historyInfoCmd)r.rH�patsZmtidsrNZlasttidZlastdbvrJZbmtidZemtidZmobjrKZtransZrpmdbvZmergedr#r#r$�historyInfoCmd#sl







zOutput.historyInfoCmdcs||j}t|t�r|g}�fdd�|D�}td�td�td�td�d��td�td�td	�td
�d��tdd�t�j��t�j��D��}|�d<|�d<d4���fdd�	}|j�}t|�dkr�t	td�d|d|d5f�nt	td�|d�t
|j�}tj
dtj|��}	t	td�|	�|jdk	�rT|j�rDt	td�|jd�nt	td�|j�|jdk	�r�|j}
tj
dtj|
��}|
|}|d6k�r�td�|}nH|d8k�r�td�|d}n,|d;k�r�td�|d<}ntd�|d>}t	td �||�|jdk	�r(|j�rt	td!�|jd�nt	td!�|j�t|ttf��rvt�}
xD|D],}||
k�rV�qD|
j|�t	td"�|��qDWnt	td"�|�t|jttf��r|j}|ddk�r�t	td#�dtd$�d�|dd�}nHt|��s�t	td#�td%��n*|�rnt	td#�td&�d'jd(d�|D���nV|jdk�r<t	td#�dtd$�d�n2|j�r\t	td#�td)�|j�nt	td#�td%��t|jttf��r�t�}
x(|jD]}||
k�r��q�|
j|��q�Wt	td*�|�nt	td*�|j�|jdk	�r t|jttf��rx0|jD]}t	td+�|��q�Wnt	td+�|j�|jdk	�rpt|jttf��r`x0|jD]}t	td,�|��qFWnt	td,�|j�|j�}|�r�t	td-��d}x(|D] }tt|��}||k�r�|}�q�Wx|D]}||d.d|d/��q�Wt	td0���j||�|j �}|�r4t	td1��d}x$|D]}|d7}t	d2||��qW|j!�}|�rxt	td3��d}x$|D]}|d7}t	d2||��qXWdS)?Ncsg|]}�j|��qSr#)r�)r8r�)r.r#r$r9tsz*Output._historyInfoCmd.<locals>.<listcomp>Z	InstalledZErased�Upgraded�
Downgraded)rBr�or�z
Not installedZOlderZNewercSsg|]}t|��qSr#)r)r8rr#r#r$r9zs�maxlenFrTc	s�d|}|r�}n�}|d}�jj�j�j|jd�j�}	|	sH|d}nB�jj|	d�}
|
r�|j|
�}|dkrpn|dkr�|d}n|d}|r��j	d�\}}
n�j	d	�\}}
t
||d
�}d}|r�|j�}td||||
|t
|�|f�dS)
Nr'rB)rxrrrYr�rFrGrZrz%s%s%s%s %-*s %s)rYr�r�ZfiltermrxZrunrX�packageZcomparerPrr�r|r�)r}Z
prefix_len�
was_installedrM�pkg_max_lenZ	show_repormZ_pkg_states�stateZipkgsZinst_pkg�resrNrOZui_repo)�_pkg_states_available�_pkg_states_installedr.r#r$�_simple_pkg~s2


z+Output._historyInfoCmd.<locals>._simple_pkgrzTransaction ID :z%u..%uz%czBegin time     :zBegin rpmdb    :z**r
�<z(%u seconds)z(%u minutes)r5z
(%u hours)z	(%u days)zEnd time       :zEnd rpmdb      :zUser           :zReturn-Code    :ZAbortedZSuccessz	Failures:z, cSsg|]}t|��qSr#)r�)r8rBr#r#r$r9�szFailure:zReleasever     :zCommand Line   :zComment        :zTransaction performed with:r�)r\r]zPackages Altered:zScriptlet output:z%4dzErrors:)FFrTr[i,i,iPFi,iPFi��iii�Q)"r?rIr�rr�rr�rHrr|r�rCr%rArBZbeg_rpmdb_versionrEZ
end_timestamprRrFror�r�rD�allr�Z
releaseverr>�commentZperformed_withr��historyInfoCmdPkgsAltered�outputr�)r.r=rUr?rxrZrbrHZbegtZbegtmZendtZendtmrh�seenrBZcodesr>reZ	perf_withZmax_lenZwith_pkgZstr_lenZt_outr�lineZt_errr#)r`rar.r$rTps�
( 







&






zOutput._historyInfoCmdrzDep-Install�	Obsoleted�
Obsoleting�Erase�	Reinstallr
rXrrW)zTrue-InstallrzDep-Installrjrkrlrmr
rXZUpdateZUpdatedc

s�|j}d}d}|j�}xH|D]@�|j�j�j�}|t|�krDt|�}tt���}||kr|}qWx�|D]��d}	�jtjj	kr�d}	d}
|r�t
�fdd�|D��r�d}
|j|
�\}}|j�j�j�}tt
|�|�}td	|	||||t���j�f�qfWd
S)aPrint information about how packages are altered in a transaction.

        :param old: the :class:`DnfSwdbTrans` to
           print information about
        :param pats: a list of patterns.  Packages that match a patten
           in *pats* will be highlighted in the output
        rr'r�z ** rGcsg|]}�j|��qSr#)r�)r8Zpat)r}r#r$r9Bsz4Output.historyInfoCmdPkgsAltered.<locals>.<listcomp>rFz%s%s%s%s %-*s %sNz    )�_history_state2uistater�r<r'rr�r^rr	ZTransactionItemState_DONEr�rPrr
r|r�)
r.r=rUZall_uistatesrZr]r�ZuistateZpkg_lenrmrMrNrOr#)r}r$rf"s2

z Output.historyInfoCmdPkgsAlteredz   )NrNr)rr)FrFN)FrFN)r0)F)N)NN)NNN)N)F)N)N)F)9�__name__�
__module__�__qualname__�__doc__r��re�compiler�r/r6rErPrS�staticmethodrW�propertyrXrYr=rjrlr2r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrr#r&r(r�rMr�rVrTrrnrfr#r#r#r$r&Cs�




/



V
$N
-
'
c

/
_2
"
MM'r&c@s(eZdZdZdd�Zdd�Zdd�ZdS)	r!zGProvides text output callback functions for Dependency Solver callback.cCs�d}|dkrtd�}n||dkr(td�}nj|dkr:td�}nX|dkrLtd	�}nF|d
kr^td�}n4|dkrptd
�}n"|dkr�td�}n|dkr�td�}|r�tj||j|j|j�dS)a�Print information about a package being added to the
        transaction set.

        :param pkgtup: tuple containing the package name, arch,
           version, and repository
        :param mode: a short string indicating why the package is
           being added to the transaction set.

        Valid current values for *mode* are::

           i = the package will be installed
           u = the package will be an update
           e = the package will be erased
           r = the package will be reinstalled
           d = the package will be a downgrade
           o = the package will be obsoleting another package
           ud = the package will be updated
           od = the package will be obsoleted
        NrBz'---> Package %s.%s %s will be installedr)z(---> Package %s.%s %s will be an upgraderz$---> Package %s.%s %s will be erasedr�z)---> Package %s.%s %s will be reinstalledrfz)---> Package %s.%s %s will be a downgraderYz(---> Package %s.%s %s will be obsoletingZudz&---> Package %s.%s %s will be upgradedZodz'---> Package %s.%s %s will be obsoleted)rr��debugrxryrz)r.r}�modergr#r#r$�	pkg_addedPs&






z"DepSolveProgressCallBack.pkg_addedcCstjtd��dS)zRPerform setup at the beginning of the dependency solving
        process.
        z"--> Starting dependency resolutionN)r�rwr)r.r#r#r$�startyszDepSolveProgressCallBack.startcCstjtd��dS)zAOutput a message stating that dependency resolution has finished.z"--> Finished dependency resolutionN)r�rwr)r.r#r#r$rqszDepSolveProgressCallBack.endN)rorprqrrryrzrqr#r#r#r$r!Ms)r!c@seZdZdd�Zdd�ZdS)�CliKeyImportcCs||_||_dS)N)r*rg)r.r*rgr#r#r$r/�szCliKeyImport.__init__cCsbdd�}td�||�|tjj|�|jdd�f}tjd|�|jjj	rJdS|jjj
rXdS|jj�S)	NcSs$tjjrdnd}|dd�jd|�S)N�0�0ri����)rZpycompZPY3�rjust)r�Zrjr#r#r$�short_id�sz'CliKeyImport._confirm.<locals>.short_idzLImporting GPG key 0x%s:
 Userid     : "%s"
 Fingerprint: %s
 From       : %szfile://rz%sTF)
rrZcryptoZ_printable_fingerprintrJr�rOr*r)Z	assumeyesZassumenorgr�)r.r�ZuseridZfingerprintr�Z	timestamprrpr#r#r$�_confirm�s


zCliKeyImport._confirmN)rorprqr/r�r#r#r#r$r{�sr{csNeZdZdZedd��Z�fdd�Zdd�Zdd	�Zd
d�Z	ddd�Z
�ZS)�CliTransactionDisplayz1A YUM specific callback class for RPM operations.cCstjjj�S)N)rr+r,�_term_width)r.r#r#r$r�szCliTransactionDisplay.<lambda>cs0tt|�j�d|_d|_d|_d|_d|_dS)NrTr0rs)�superr�r/�lastmsg�lastpackagerg�mark�marks)r.)�	__class__r#r$r/�szCliTransactionDisplay.__init__c	Csjtjjj|�}|dkrdS|j�}t|�}	||_|dkr>d}
n|td�|}
|j|||||
||	|�dS)a�Output information about an rpm operation.  This may
        include a text progress bar.

        :param package: the package involved in the event
        :param action: the type of action that is taking place.  Valid
           values are given by
           :func:`rpmtrans.TransactionDisplay.action.keys()`
        :param ti_done: a number representing the amount of work
           already done in the current transaction
        :param ti_total: a number representing the total amount of work
           to be done in the current transaction
        :param ts_done: the number of the current transaction in
           transaction set
        :param ts_total: the total number of transactions in the
           transaction set
        Nr�d)	rr	�ACTIONSr<�_max_action_widthr
r�r�
_out_progress)r.r[r�ti_done�ti_total�ts_done�ts_totalZ
action_str�wid1�pkgname�percentr#r#r$r-�szCliTransactionDisplay.progresscCsHt|d�s>d}x(tjjj�D]}t|�}||kr|}qW||_|j}|S)N�_max_action_wid_cacher)�hasattrrr	r�r�r
r�)r.r�rCZwid_valr#r#r$r��s
z'CliTransactionDisplay._max_action_widthc	Cs�|jr�tjj�s||kr�|j|||tjj�||d�\}	}}
t|�}|	t|||�t||
|
�f}||jkr�tj	j
d|tj�||_||kr�td�dS)N)r-r�r�Zwrite_flushr')rgrr �isatty�_makefmtr
rr�rr��_terminal_messengerr|)r.r�r�r�r�r�Zprocessr�r�rL�wid2rpr#r#r$r��s

z#CliTransactionDisplay._out_progressTN�cCs�tt|��}d||f}d|d|d}	|	||f}
|dkrFd}nt|�}d|d}|d|d7}|d7}|d7}|d7}|j}
|
|kr�|}
|
|8}
||
dkr�|
d}|j||}d||f}
d|
d	}||d}|r�|d
kr�d|
}|}n�|�rD|dk�r*||jt||d
�f}nd}d|d|
}|}nL|d
k�r\d|
}|}n4|dk�rx||j|f}nd}d|d|
}|}|||fS)Nz%s.%s�%zs/%�srsrZrz[%-zs]r�z
  %s: %s   r
gY@rz

  %s: %s r'z  %s: %s   z	  %s: %s )rr�r
rir�r�)r.r�r�r�r-r�r��lr�Zfmt_donerKZpnlZoverheadrir�Zfmt_barZfull_pnlrLr�Zbarr#r#r$r��sP


zCliTransactionDisplay._makefmt)TNr�)rorprqrrrvrir/r-r�r�r��
__classcell__r#r#)r�r$r��s
 r�c
Cs�d}tjj�sdS|dkr d}n|dkr6t|�|}nd}tjjj�}|dkrZ||krZd}d||f}|t|�d8}|dkr�d}|dkr�|d8}|dkr�d}|t	||�}d|||f}n�||kr�d	t
|||�|f}nb|d
8}|dkr�d}|d}	|	t|�k�rt|�}	||	8}|t	||�}dt
||	|	�|||f}||k�rZtjj
d|tj�||k�rvtjj
dd
tj�tjj
dtjd�dS)aIOutput the current status to the terminal using a simple
    text progress bar consisting of 50 # marks.

    :param current: a number representing the amount of work
       already done
    :param total: a number representing the total amount of work
       to be done
    :param name: a name to label the progress bar with
    r:Nrr$z %d/%drrZz	
[%-*s]%sz
%s%sr�z

%s: [%-*s]%s�writer��flush)r�)rr r�r�rr+r,r�rr�rr
r�r�)
rTZtotalrxr�r�rirqZhashbarrgZnwidr#r#r$r"sL



r")N)<rrZ
__future__rrrr�r�rZlibdnf.transactionrZloggingr?r1rsrr%Zdnf.cli.formatrrZdnf.i18nrrr	r
rrr
rZ
dnf.pycomprrrrrZdnf.yum.rpmtransrZdnf.db.historyrZdnf.baserZdnf.callbackZdnf.cli.progressZdnf.cli.termZdnf.confZ
dnf.cryptoZdnf.transactionZdnf.utilZdnf.yum.miscZ	getLoggerr�r%�objectr&�callbackZDepsolver!Z	KeyImportr{r�r"r#r#r#r$�<module>sb(

7