3 ©ft`Zã@sœdZddlmZddlmZddlmZddlZddlZddlZddlZ ddl Z ddl Z ddl 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_lengthZ right_countZ missing_itemsZlst_iter©r#ú/usr/lib/python3.6/output.pyÚ_spread_in_columns6s r%c @s eZdZdZdmZejdƒZdd„Zdd„Z d d „Z d d „Z d 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"dd?„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$ú Vsz&Output._col_widths..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|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.rwZfillrDZname_lenZbegrpr#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..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..format_key_val_fillrŽÚshortÚNamerz%s%s%sZEpochÚVersionZReleaseÚArchÚ ArchitectureÚSizeZSourceÚRepoÚ Repositoryz From repoZPackagerZ Buildtimez Install timeNz Installed byZSummaryZURLZLicenseZ Descriptionrˆ)&rPrrr`rwZepochrÚversionÚreleaserxrÚfloatÚ_sizeZ sourcerpmÚrepoidÚ _from_systemrXZrepor)ÚverboseZpackagerrÚutilZnormalize_timeZ buildtimeZ installtimeZ package_dataÚintÚ_itemZgetInstalledByÚ ValueErrorÚ_pwd_ui_usernameÚsummaryÚurlr ÚlicenseÚ descriptionr�) r.r|rMr’r“Z output_listrNrOrŠZ history_repoZ history_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 compactPrintrwrxr 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' - highlighting used when the package has a higher version number :return: number of packages listed rÚinforwÚnevrarz%sFznot inrGr0ú>rFú    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_namesrwr#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Ër1rwr|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  |d f}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)rw)r8r|r#r#r$ú âsz?Output.display_pkgs_in_groups..names..)r])Úpackagesr#r#r$Únamesász,Output.display_pkgs_in_groups..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ËZ col_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)rw)r8r×r#r#r$rÑ szFOutput.display_groups_in_environment..names..)r])Úgroupsr#r#r$rÓsz3Output.display_groups_in_environment..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.Z environmentrÓ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..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..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..zOther : %s)F)r)Zshowdupesfromreposrwrxr‹r¨Zcolor_search_matchrSr{r¢rrƒr¸r«r©rªZprovidesr‘rärKÚany)r.rçr¹rßr¢rMrèrorå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Ú ExceptionZ installsizerÚloggerÚerrorr´r) r.rÒZ installonlyÚtotsizeZlocsizeZinsizerðr|Úsizeror#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òror#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 |ƒƒ}|j j |ƒ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\}}x2t+|ƒD]&}|j&d||fddddddfƒ�qW�qW|j&| |fƒt!t'ˆj j(j,ƒƒj*ƒƒ}|�rØt dƒ} g}xF|D]>\}}x2t+|ƒD]&}|j&d||fddddddfƒ�qšW�qˆW|j&| |fƒt!t'ˆj j(j-ƒƒj*ƒƒ}|�rW|j&| |fƒˆj j1j7j3}"|"�r²t d$ƒ} g}x |"j4ƒD]}|j&||ƒƒ�qŒW|j&| |fƒˆj j1j7j5}#|#�rt d%ƒ} g}x |#j4ƒD]}|j&||ƒƒ�qÚW|j&| |fƒˆj j1j7j6}$|$�rNt d&ƒ} g}x |$j4ƒD]}|j&||ƒƒ�q(W|j&| |fƒˆj8j9 �rvˆj j:j;|@�rvg}ˆj j|&ƒ}'d/d0„|Dƒ}|j&|'|fƒg}x*t!|j*ƒƒD]\}(}%| ||| |%gƒ} �qWt d1ƒ}'ˆj j8j?�rN|'d}'n |'t d2ƒ}'d3d0„|Dƒ}|j&|'|fƒˆj@jA})|d4 �rˆj j(jBƒ �rˆj j1�o¸ˆj j1j7�p¸ˆj j1j2 �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|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)ZpkgtupryrzrrŸr¡r)r²Z _from_cmdliner±r®r`rÚ setdefaultÚmax)ÚlinesrcÚa_widrçÚ obsoletesr¾ÚaÚerúrûryr ròÚhirf)r.r#r$Ú _add_lineþs"   ,z*Output.list_transaction.._add_linez Installing group/module packageszInstalling group packagesr¨Z InstallingZ UpgradingZ ReinstallingzInstalling dependencieszInstalling weak dependenciesZRemovingzRemoving dependent packageszRemoving unused dependenciesZ DowngradingcSs|jS)N)r|)Úxr#r#r$Ú4sz)Output.list_transaction..)rŠzInstalling module profilesz%s/%srzDisabling module profileszEnabling module streamszSwitching module streamsz%s -> %srzDisabling moduleszResetting modulescSs&|jƒ}|r|ntdƒddddddfS)Nz r)ZgetNamer)r×rwr#r#r$Ú format_lineqsz,Output.list_transaction..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..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..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°ZUPGRADEZ UPGRADE_ALLZ DISTUPGRADEZDISTUPGRADE_ALLZ DOWNGRADEÚINSTALLr¸rr£Z _make_listsr*Z WITH_MODULESrrrÅZupgradedZ reinstalledZinstalled_groupZ installed_depZinstalled_weakZerasedZ erased_depZ erased_cleanZ downgradedÚactionÚlibdnfrZTransactionItemAction_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²rwrxryrr r rrýr )Qr.rreZforward_actionsZskipped_conflictsZskipped_brokenZ list_bunchZ pkglist_linesrcrÿrZ ins_group_msgrZpkglistrþZreplacesÚtsirBZ obsoletedZinstalledProfilesrwZprofilesZprofileZremovedProfilesZenabledStreamsÚ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_widthZ msg_packageZmsg_archZ msg_versionZmsg_repositoryZmsg_sizerøZtotalmsgr¾rryr ròrrrorNrOZobspoZappendedZ summary_dataZmax_msg_actionZ max_msg_countZ max_msg_pkgsZmax_msg_depcountr‰ZdepcountZmsg_pkgsZlen_msg_actionZ len_msg_countZ len_msg_pkgsZlen_msg_depcountZ msg_deppkgsZ action_msgr#)r.r$Úlist_transactionësè$         ,,.               $                   zOutput.list_transactionc sćfdd„}|sdSg}g}|jdj|ƒƒx|D]}|jt|ƒƒq2Wxd D]}|||ƒ}|rNPqNW|szˆjjd  g}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_lensrgrorh)r.r#r$Ú _fits_in_colsKs(    z+Output._pto_callback.._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.rr#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ýÚtimerrr rr)r.Z remote_sizeZdownload_start_timestampriZdl_timeror#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¸rrrZTransactionItemAction_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..ìÿÿéÿÿÿzZSystemr'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.._safe_split_0ú;rZz%s <%s>z %s ... <%s>z<%s>)r*r+) rIrrrr ÚpwdÚgetpwuidr¤Zpw_gecosZpw_namerÏ) r.r¬r)Zloginidrwr.ÚuserÚfullnameZ user_namer#)r)r.r$r§´s*    zOutput._pwd_ui_usernamec Csj|jj|ƒ}|jjdkr"ddg}nV|jjdkr6dg}nBtƒ}d}d}x2|D]*}|d7}|jdkrh|d7}|j|jƒqJWd}t|ƒdkrÐt dƒ} |j j } | dkr®t j j jdƒ} | dkrºd } | d krÊ| 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�rlt|ƒ}xø|D]ð}t|ƒdk�r’|j�pŽd} n|j|jd ƒ} t| ƒ} tjdtj|jƒƒ} |j|jƒƒ\}}t| | | ƒ} t|ddƒ}d}}|jdk�rd}}n"|j�rd}}n|j�r&d}}|j�r2d}|j�r>d }t||j| | ||fd!||fƒ�qrWdS)#z›Output a list of information about the history of yum transactions. :param tids: transaction Ids; lists all transactions if empty ZusersrrZZcommandsrNz%s | %s | %s | %s | %sz Command lineééOé7z User nameZIDrz Date and timersz 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_viewr¸Ú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ÚfmtrwZ real_colsZ name_widthZ table_widthZtmrZuiactsZrmarkZlmarkr#r#r$ÚhistoryListCmdÖsp                 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 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.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)rwrrrXr¾rFrGrYrz%s%s%s%s %-*s %s)rYrÄrÅZfiltermrwZrunrXÚpackageZcomparerPr rƒr{r‘)r|Z prefix_lenÚ was_installedrMÚ pkg_max_lenZ show_reporlZ _pkg_statesÚstateZipkgsZinst_pkgÚresrNrOZui_repo)Ú_pkg_states_availableÚ_pkg_states_installedr.r#r$Ú _simple_pkg~s2    z+Output._historyInfoCmd.._simple_pkgrzTransaction ID :z%u..%uz%czBegin time :zBegin rpmdb :z**r é<z (%u seconds)z (%u minutes)r4z (%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¹rGrr{ržrBr$r@rAZbeg_rpmdb_versionrDZ end_timestamprQrErnr¸rºrCÚallr�Z releaseverr=ÚcommentZperformed_withr‘ÚhistoryInfoCmdPkgsAlteredÚoutputrð)r.r<rTr>rwrYrarGZbegtZbegtmZendtZendtmrhÚseenrBZcodesr=rdZ perf_withZmax_lenZwith_pkgZstr_lenZt_outrÚlineZt_errr#)r_r`r.r$rSpsÖ   (             &                   zOutput._historyInfoCmdr z Dep-InstallÚ ObsoletedÚ ObsoletingÚEraseÚ Reinstallr rWr rV) z True-Installr z Dep-Installrirjrkrlr rWZUpdateZUpdatedc 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..rFz%s%s%s%s %-*s %sNz )Ú_history_state2uistaterÒr<r&rr‘r]rrZTransactionItemState_DONErërPr r r{rƒ) r.r<rTZ all_uistatesrYr\rÒZuistateZpkg_lenrlrMrNrOr#)r|r$re"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=rjrkr2rr„r…r†r‹r�r­r³r»rÃrÉrÌrÎrÐrÙrÛrìrírórôrùrrrr"r%r'r§rLr¸rUrSrrmrer#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 downgraderXz(---> Package %s.%s %s will be obsoletingZudz&---> Package %s.%s %s will be upgradedZodz'---> Package %s.%s %s will be obsoleted)rrïÚdebugrwrxry)r.r|Úmoderfr#r#r$Ú pkg_addedPs&       z"DepSolveProgressCallBack.pkg_addedcCstjtdƒƒdS)zRPerform setup at the beginning of the dependency solving process. z"--> Starting dependency resolutionN)rïrvr)r.r#r#r$ÚstartyszDepSolveProgressCallBack.startcCstjtdƒƒdS)zAOutput a message stating that dependency resolution has finished.z"--> Finished dependency resolutionN)rïrvr)r.r#r#r$rpszDepSolveProgressCallBack.endN)rnrorprqrxryrpr#r#r#r$r Ms)r c@seZdZdd„Zdd„ZdS)Ú CliKeyImportcCs||_||_dS)N)r*rf)r.r*rfr#r#r$r/…szCliKeyImport.__init__cCsbdd„}tdƒ||ƒ|tjj|ƒ|jddƒf}tjd|ƒ|jjj rJdS|jjj rXdS|j j ƒS) NcSs$tjjr dnd}|dd…jd|ƒS)NÚ0ó0riøÿÿÿ)rZpycompZPY3Úrjust)rÕZrjr#r#r$Úshort_id‹sz'CliKeyImport._confirm..short_idzLImporting GPG key 0x%s: Userid : "%s" Fingerprint: %s From : %szfile://rz%sTF) rrZcryptoZ_printable_fingerprintrJrïrNr*r)Z assumeyesZassumenorfrÃ)r.rÕZuseridZ fingerprintr©Z timestampr~ror#r#r$Ú_confirm‰s    zCliKeyImport._confirmN)rnrorpr/rr#r#r#r$rz„srzcsNeZdZdZedd„ƒZ‡fdd„Zdd„Zdd „Zd d „Z ddd„Z ‡Z S)ÚCliTransactionDisplayz1A YUM specific callback class for RPM operations.cCs tjjjƒS)N)rr+r,Ú _term_width)r.r#r#r$r¢szCliTransactionDisplay.cs0tt|ƒjƒd|_d|_d|_d|_d|_dS)NrTr0rr)Úsuperr€r/ÚlastmsgÚ lastpackagerfÚ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.rZrÚ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)Úhasattrrrr‰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�t dƒdS)N)r-r‘r�Z write_flushr') rfrrÚisattyÚ_makefmtr r rƒrr£Ú_terminal_messengerr{) r.rŒr�rŽr�r’Zprocessr‘r�rKÚwid2ror#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/%ÚsrrrZrz[%-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_donerJZpnlZoverheadrir†Zfmt_barZfull_pnlrKr˜Zbarr#r#r$r–èsP            zCliTransactionDisplay._makefmt)TNr™) rnrorprqrurir/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 ||ƒ}d t || | ƒ|||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 r9Nrr#z %d/%drrZz [%-*s]%sz %s%srŒz %s: [%-*s]%sÚwriterˆÚflush)rø)rrr•ržrr+r,r�rr¤r r r£r—) rTZtotalrwr…r’rirpZhashbarrfZnwidr#r#r$r!sL       r!)N)sb   (    7