3 ft`Z@sdZddlmZddlmZddlmZddlZddlZddlZddlZ 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 Z2Gddde3Z4Gddde'j5j6Z7Gddde'j5j8Z9Gddde#Z:dddZ;dS)z"Handle actual output from the cli.)absolute_import)print_function)unicode_literalsN) format_number format_time)_C_P_ucdfill_exact_width textwrap_fill exact_widthselect_short_long)xrange basestringlongunicode sys_maxsize)TransactionDisplay)MergedTransactionWrapperdnfcCsrtj|ftjd}t|}|d}| |}|s@tjd|}n|rR|jd|t|}tt|f|g|S)N)r) itertoolschainrepeatlenextenditerlistzip)Z cols_countZlabellstleftZ lst_lengthZ right_countZ missing_itemsZlst_iterr#/usr/lib/python3.6/output.py_spread_in_columns6s r%c @s eZdZdZdmZejdZddZddZ d d Z d d Z d dZ e ddZeddZeddZdnddZe ddZddZdoddZdpd!d"Zdqd#d$Zd%d&Zd'd(Zd)d*Zdrd,d-Zdsd.d/Zdtd0d1Zidifd2d3Zdud4d5Zd6d7Z d8d9Z!d:d;Z"dd?Z$d@dAZ%dvdBdCZ&dwdDdEZ'dxdFdGZ(dHdIZ)dJdKZ*dydLdMZ+dNdOZ,dPdQZ-dRdSZ.dTdUZ/dVdWZ0dzdXdYZ1d{dZd[Z2ge3fd\d]Z4gfd^d_Z5e6d`e6d`e6dae6dbe6dce6dde6dee6dfe6dge6dhe6didj Z7gfdkdlZ8dS)|Outputz+Main output class for the yum command line. z ^\*{0,2}/cCs$||_||_tjjj|_d|_dS)N)confbaserclitermZTermprogress)selfr*r)r#r#r$__init__IszOutput.__init__cCs0|jj}dd|}|jt||d}|||fS)Nz%s=r')r,columns fmtColumnsr )r.col_datarowZ term_widthZruleheaderr#r#r$_bannerOs zOutput._bannerc Cszdd|dD}xF|D]>}x8t|D],\}}||}t|}|j|dd||<q&WqW|j|ddd}tttj|S)NcSsg|] }tqSr#)dict).0rr#r#r$ Vsz&Output._col_widths..rrz )indent) enumeraterget calcColumnsrmapoperatorneg) r.rowsr3r4ivalZcol_dctZlengthcolsr#r#r$ _col_widthsUs zOutput._col_widthscCs(d}d}|snt|t s$|dkr2|jjd}n|dkr|St|}t||||d}|jddkr||dkrt|||d d}|S) zReturn 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$ fmtKeyValFills zOutput.fmtKeyValFillr0cCsht|}|jjd}t|}||dkr6|d}}n$|||d}|||t|}d|||fS)aFormat 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 rZz%s %s %s)r r,r1r r)r.rwZfillrDZname_lenZbegrpr#r#r$ fmtSections   zOutput.fmtSectionc sdd}fdd}g}j|\}}tdtddtdd}|j||d ||j|f|jrv|j|td |jtdtdd tdd }|j|||j|j|td |jtdtdd tdd}|j|||j tdtddtdd}|j||t t |j |j|td|j tdtddtdd}|j|||j|jrjj|} | r|j|td| jjr>|j|td|j|j|tdtjj|j|jr|j|tdtjj|jjj|} | r>yt| jj} Wntk r"d} YnX|j|tdj| tdtddtdd}|j|||j |j!r|j|tdt"|j!|j|td|j#tdtddtdd}|j|||j$dj%|S)zPrint information about the given package. :param pkg: the package to print information about :param highlight: highlighting options for the name of the package cSsdjt|dddt|gS)Nr' :)joinr str)rrCr#r#r$format_key_valsz)Output.infoOutput..format_key_valcsjt|ddd|pdS)Nrz : r)rr )rrC)r.r#r$format_key_val_fillsz.Output.infoOutput..format_key_val_fillrshortNamerz%s%s%sZEpochVersionZReleaseArch ArchitectureSizeZSourceRepo Repositoryz From repoZPackagerZ Buildtimez Install timeNz Installed byZSummaryZURLZLicenseZ Descriptionr)&rPrrr`rwZepochrversionreleaserxrfloat_sizeZ sourcerpmrepoid _from_systemrXZrepor)verboseZpackagerrutilZnormalize_timeZ buildtimeZ installtimeZ package_dataint_itemZgetInstalledBy ValueError_pwd_ui_usernamesummaryurlr license descriptionr) r.r|rMrrZ output_listrNrOrZ history_repoZ history_pkguidr#)r.r$ infoOutputsh                   zOutput.infoOutputc Cs|\}}|dk rV|jj}|jtjkr,|jj}|j|||d|j||d|jjddS|j}d|j |j f}|j } t d|| ||fdS) 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_remotereponamehawkeyZSYSTEM_REPO_NAMEcolor_update_localrcolor_update_installedZ compactPrintrwrxrr{) r.ZuotupZ changetyper1Z changePkgZinstPkgZchiZ c_compactZ i_compactZc_repor#r#r$updatesObsoletesLists   zOutput.updatesObsoletesListc Csl|dkrht|dkr`td|t}|dkrbi}x"|D]} | |t| t| j<q' - highlighting used when the package has a higher version number :return: number of packages listed rinforwnevrarz%sFznot inrGr0>rF    zOutput.userconfirmcCs~|jjjj}|jjjj}i}xPtjtt|dD]6}||kr^||d||<q@||kr@||d||<q@W|S)Nrr) rYquery installedZ _name_dict availablerrrr )r.sectionsrrrfpkg_namer#r#r$_pkgs2name_dictszOutput._pkgs2name_dictc Csi}i}x~tjtt|dD]d}|j|}|dkr8q tt|t|j}tt|j}|j|dd||<|j|dd||<q W||fS)Nrr) rrrr r<r r GRP_PACKAGE_INDENTr) r.r name_dictZ nevra_lengthsZ repo_lengthsrr|Znevra_lZrepo_lr#r#r$_pkgs2col_lengthss zOutput._pkgs2col_lengthscCs$x|D]}td|j|fqWdS)Nz%s%s)r{r)r. pkg_namesrwr#r#r$_display_packagess zOutput._display_packagescCspxj|D]b}y ||}Wn(tk r>td|j|fwYnXd}|jsR|jj}|j|d|j||dqWdS)Nz%s%sFT)r}r:rMr1)KeyErrorr{rrr)Zcolor_list_available_installr)r.rrr1rwr|rMr#r#r$_display_packages_verboses  z Output._display_packages_verbosec Csldd}tdtd|j|jj}|r@ttdt|j|jr`ttdt|jp\d|jrxttd|jtd ||j ftd ||j ftd ||j ftd ||j ff}|r0|j |}|j||}|j|}|d  |d f}xp|D].\}} t| dkrqt||j| ||qWn8x6|D].\}} t| dkrPq6t||j| q6WdS)zOutput information about the packages in a given group :param group: a Group object to output information about cSstdd|DS)Ncss|] }|jVqdS)N)rw)r8r|r#r#r$ sz?Output.display_pkgs_in_groups..names..)r])packagesr#r#r$namessz,Output.display_pkgs_in_groups..namesrz Group: %sz Group-Id: %sz Description: %srz Language: %sz Mandatory Packages:z Default Packages:z Optional Packages:z Conditional Packages:rrN)r{rui_namer)rr idui_descriptionZ lang_onlyZmandatory_packagesZdefault_packagesZoptional_packagesZconditional_packagesrrr=rrr) r.grouprrrrZ col_lengthsr1 section_namerr#r#r$display_pkgs_in_groupss8   zOutput.display_pkgs_in_groupscCsdd}ttd|j|jjr8ttdt|j|jr\t|jpJd}ttd|td||jftd||j ff}x0|D](\}}t |d krqt||j |qWd S) zOutput information about the packages in a given environment :param environment: an Environment object to output information about cSstdd|DS)Ncss|] }|jVqdS)N)rw)r8rr#r#r$r szFOutput.display_groups_in_environment..names..)r])groupsr#r#r$rsz3Output.display_groups_in_environment..nameszEnvironment Group: %sz Environment-Id: %srz Description: %sz Mandatory Groups:z Optional Groups:rN) r{rrr)rr rrZmandatory_groupsZoptional_groupsrr)r.Z environmentrrrrrr#r#r$display_groups_in_environments z$Output.display_groups_in_environmentcsVdfdd fdd}jjr4d}ndjjf}j|jpRd}r|d krjjjj|d d }t||d krjj }|sd Stt d j d}d} xXt |D]J} j| krd } qˆj | krt d } | | |d dd }qˆj| kr,t d} | | |ddd }qˆj| krVt d} | | |ddd }q|| |rhd }qt d} xjD]} t| } tj| | r| | |ddd }n`| jd} t dtfdd| Dr| jd}n| }tj| |rx| | |ddd }qxWqWt|| gsLx*t |D]} t d} | | |ddq*Wtd S)aOutput 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|sttdt|pd}|dkr(dSr>j|dd}|rTtj||n t||dS)Nz Matched from:rT) ignore_case)r{rr rSr)ritemZprinted_headline can_overflow)rMmatchforr.r#r$print_highlighted_key_item's  z8Output.matchcallback..print_highlighted_key_itemcsTjj|sdStd}d}x2jD](}tj||r$|||p@|ddd}q$W|S)NFzFilename : %s)rT)FILE_PROVIDE_REmatchrfilesfnmatch)r printed_matchrZ file_matchfilename)porr.r#r$print_file_provides4s   z1Output.matchcallback..print_file_providesz%s : z%s.%s : rNT)rzRepo : %szDescription : )rzURL : %szLicense : %szProvide : %srz=<>c3s|]}|kVqdS)Nr#)r8char)possibler#r$rpsz'Output.matchcallback..zOther : %s)F)r)ZshowdupesfromreposrwrxrrZcolor_search_matchrSr{rrrrrrrZprovidesrrrKany)r.rrrrrMrrorZ name_matchrrZprovideZ first_provideZitem_newr#)rMrrrrr.r$ matchcallbacksp           zOutput.matchcallbackcCs|j|||ddS)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.rrrr#r#r$matchcallback_verboses zOutput.matchcallback_verbosec Csd}d}d}d}x|D]}yrt|j}||7}y|jr@||7}Wntk rVYnX|s^wyt|j}Wntk rYnX||7}Wqtk rd}td} tj| PYqXqW|s|rtjtdt |||krtjtdt |||rtjtdt |dS) zReport 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) rrZverifyLocalPkg ExceptionZ installsizerloggererrorrr) r.rZ installonlytotsizeZlocsizeZinsizerr|sizeror#r#r$reportDownloadSizesD          zOutput.reportDownloadSizec Csrd}d}xL|D]D}y|j}||7}Wqtk rPd}td}tj|PYqXqW|sntjtdt|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)rrrrrrr)r.rrrr|rror#r#r$reportRemoveSizes    zOutput.reportRemoveSizec Cs*|sdSg}g}|jr$|jtdxJ|jD]@}t|j|}|j|}|rR|jn|} |jtdd| |q,W|j r|jtdx@|j D]6}t|j |}|j j |j} |jtdd| |qW|r |j |} x$|D]} |j|jt| | dqW|j| tdtdddf|d d <d j|S) Nz+Marking packages as installed by the group:r@z)Marking packages as removed by the group:r'ZGroupPackagesrrr)Z new_groupsr`rrZadded_packagesZ _group_by_idrrr%Zremoved_groupsZremoved_packagesrr<rEr2r r6r) r.compsrXrhoutrAZgrp_idZpkgsZ group_objectZgrp_namer3r4r#r#r$list_group_transactions.     $zOutput.list_group_transactioncQ s tjtjBtjBtjBtjBtjB}t}t}|dkr\}}x2t+|D]&}|j&d||fddddddfqWqW|j&| |ft!t'j j(j,j*}|rt d} g}xF|D]>\}}x2t+|D]&}|j&d||fddddddfqWqW|j&| |ft!t'j j(j-j*}|rW|j&| |fj j1j7j3}"|"rt d$} g}x |"j4D]}|j&||qW|j&| |fj j1j7j5}#|#rt d%} g}x |#j4D]}|j&||qW|j&| |fj j1j7j6}$|$rNt d&} g}x |$j4D]}|j&||q(W|j&| |fj8j9 rvj j:j;|@rvg}j j|&}'d/d0|D}|j&|'|fg}x*t!|j*D]\}(}%| ||| |%g} qWt d1}'j j8j?rN|'d}'n |'t d2}'d3d0|D}|j&|'|fj@jA})|d4 rˆj j(jB rˆj j1oj j1j7pj j1j2 rdS|d4i|d5|d6ig}d| ddd7g}*jC|d8|*d9|d:}*|*\}+} },}-}.tD|*d7}/|)|/kr&|)n|/})tE|+td;d<td=d<}0tE| td;d>td=d?}1tE|,td;d@td=d@}2tE|-td;dAtd=dB}3tE|.td;dCtd=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}>jGj8jH\}?}@xBt!|<D]6}AdHt dIdJ}B|B|?|AjI|@|AjJ|AjKf;}B|>|B7}> qrW|6|>}6 q W|r|5j&|6qW|5j&t dKdE|)t dLtL|jtL|jtL|jtL|jdft dMtL|jdft dNtL|jtL|jtL|jdft dOtL|jdft dPtL|tL|dff}Cd}Dd}Ed}Fd}Gx|CD]\} }H}I|H r|I r qtMd|5j&|>|P|E|HdU|F|Jf|G|I|Ofn$dV}>|5j&|>|P|E|Fd.|G|I|Ofn&|H r$dW}>|5j&|>tQ| |D|E|H|Jf q$Wdj>|5S)Xz]Return a string representation of the transaction in an easy-to-read format. N)rvrrcs|j\}}}}} |j} |j} t|j} |dkr2d}|jrBjj} n|jrRjj } njj } |j ||| | | || fxRdt |fdt | fdt | ffD],\}}||j |d|||d7<qWt|t |}|S)NZnoarchrrrrr)Zpkgtupryrzrrrr)rZ _from_cmdlinerrr`r setdefaultmax)linesrca_widr obsoletesraerrryrrhirf)r.r#r$ _add_lines"   ,z*Output.list_transaction.._add_linez Installing group/module packageszInstalling group packagesrZ InstallingZ UpgradingZ ReinstallingzInstalling dependencieszInstalling weak dependenciesZRemovingzRemoving dependent packageszRemoving unused dependenciesZ DowngradingcSs|jS)N)r|)xr#r#r$4sz)Output.list_transaction..)rzInstalling module profilesz%s/%srzDisabling module profileszEnabling module streamszSwitching module streamsz%s -> %srzDisabling moduleszResetting modulescSs&|j}|r|ntdddddddfS)Nz r)ZgetNamer)rrwr#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$rsz*Output.list_transaction..z--bestz--allowerasingzSSkipping packages with conflicts: (add '%s' to command line to force their upgrade)r'cSsg|]}|dddqS)Nrrr[)rr#)r8rBr#r#r$r9sz+Output.list_transaction..z,Skipping packages with broken dependencies%sz or part of a groupcSsg|]}|dddqS)Nrrr[)rr#)r8rBr#r#r$r9srrrz rZ)r:r1rdrerZPackagerrrrrrrz %s %s %s r0z%s: rz Z replacingz %s%s%s.%s %s z Transaction Summary %s InstallUpgradeZRemove DowngradeZSkiprzDependent packagezDependent packagesz%s %*d %s (+%*d %s) z%-*sz%s %s ( %*d %s) z %s %*d %s )RrZUPGRADEZ UPGRADE_ALLZ DISTUPGRADEZDISTUPGRADE_ALLZ DOWNGRADEINSTALLrrrZ _make_listsr*Z WITH_MODULESrrrZupgradedZ reinstalledZinstalled_groupZ installed_depZinstalled_weakZerasedZ erased_depZ erased_cleanZ downgradedactionlibdnfrZTransactionItemAction_OBSOLETEDrZ getReplacedByrrr]ZFORWARD_ACTIONSZTransactionItemAction_REMOVEr<r|r`r7Z_moduleContainerZgetInstalledProfilesr^rZgetRemovedProfilesZgetEnabledStreamsZgetSwitchedStreamsZgetDisabledModulesZgetResetModulesZ_historyenvZ _installedrZ _upgradedZ_removedrr)ZbestZ_goalactionsZ_skipped_packagesZ_allow_erasingrZupgrade_group_objects_upgrader,r1Z isChangedr=rarr2rPrrwrxryrr r rrr )Qr.rreZforward_actionsZskipped_conflictsZskipped_brokenZ list_bunchZ pkglist_linesrcrrZ ins_group_msgrZpkglistrZreplacestsirBZ obsoletedZinstalledProfilesrwZprofilesZprofileZremovedProfilesZenabledStreamsstreamZswitchedStreamsZdisabledModulesZ resetModulesrZinstall_env_grouprZupgrade_env_groupZremove_env_groupZ install_groupZ upgrade_groupZ remove_groupr|ZrecommendationsZskip_strrZ output_widthr1Zn_widZv_widZr_widZs_widZ real_widthZ msg_packageZmsg_archZ msg_versionZmsg_repositoryZmsg_sizerZtotalmsgrrryrrrrrorNrOZobspoZappendedZ summary_dataZmax_msg_actionZ max_msg_countZ max_msg_pkgsZmax_msg_depcountrZdepcountZmsg_pkgsZlen_msg_actionZ len_msg_countZ len_msg_pkgsZlen_msg_depcountZ msg_deppkgsZ action_msgr#)r.r$list_transactions$         ,,.               $                   zOutput.list_transactionc sfdd}|sdSg}g}|jdj|x|D]}|jt|q2Wxd D]}|||}|rNPqNW|szjjd  g}xD|r|dt|} |jd jjt| ||t|d}q|W|S)Ncst||krgSjj|dd}|dkr0gSdg|}d}x`|D]X}t|||krt|||}||krtgS||8}t|||<|d7}|t|;}qDWx8tt|D](}||||7<||d9<qW|S)zb Work out how many columns we can use to display stuff, in the post trans output. rrZrr[)rr,r1r\)msgsnumr"Zcol_lensrgrorh)r.r#r$ _fits_in_colsKs(    z+Output._pto_callback.._fits_in_colsrz{}:r rr(rZz {})rrrr rr(rZ)r`formatrr,r1rr2r ) r.rZtsisrrrrrrDZ current_msgsr#)r.r$ _pto_callbackHs&    zOutput._pto_callbackcCstjj|j||jS)z{ Return a human-readable summary of the transaction. Packages in sections are arranged to columns. )rrZ_post_transaction_outputr*r)r.rr#r#r$post_transaction_outputzszOutput.post_transaction_outputcCs@d}|jjdkr6tjjjtjd}tjjjtjd|_|tfS)z_Set up the progress callbacks and various output bars based on debug level. NrZ)Zfo) r)Z debuglevelrr+r-ZMultiFileProgressMetersysstdoutDepSolveProgressCallBack)r. progressbarr#r#r$setup_progress_callbackss  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{Gz?z %5sB/s | %5sB %9s ZTotal) r,r1rrrtimerrr rr)r.Z remote_sizeZdownload_start_timestampriZdl_timeror#r#r$download_callback_total_cbs  z!Output.download_callback_total_cbcCst}t}d}xD|D]<}|jtjjtjjfkr2q|j|j|j|j|d7}qWt |dkrt|dj t |fS|dj t |fS)Nrrz, r) rrrrZTransactionItemAction_UPGRADEDZ TransactionItemAction_DOWNGRADEDr action_nameZ action_shortrrr]r)r.ZhpkgsrZ actions_shortrr|r#r#r$_history_uiactionss     zOutput._history_uiactionsc st|trfdd|DS|dks.|dkrftd}tdd|}dk r^t|kr^|}t|Sdd }yrtjt|}|t|jd d }t|j }d ||f}dk rt|krd |||f}t|krd|}|St k rt|SXdS)Ncsg|]}j|qSr#)r)r8u)limitr.r#r$r9sz+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)textargsrUr#r#r$ _safe_split_0s z.Output._pwd_ui_username.._safe_split_0;rZz%s <%s>z %s ... <%s>z<%s>)r*r+) rIrrrr pwdgetpwuidrZpw_gecosZpw_namer) r.rr)Zloginidrwr.userfullnameZ user_namer#)r)r.r$rs*    zOutput._pwd_ui_usernamec Csj|jj|}|jjdkr"ddg}nV|jjdkr6dg}nBt}d}d}x2|D]*}|d7}|jdkrh|d7}|j|jqJWd}t|dkrt d} |j j } | dkrt j j jd} | dkrd } | d kr| d nd } n t d } d } t|tt d ddt| | | tt dddtt dddtt dddfd"| dddddd} td| d}|dkrlt|}x|D]}t|dkr|jpd} n|j|jd } t| } tjdtj|j} |j|j\}}t| | | } t|dd}d}}|jdkrd}}n"|jrd}}n|jr&d}}|jr2d}|jr>d }t||j| | ||fd!||fqrWdS)#zOutput 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 lineO7z User nameZIDrz Date and timersz Action(s)ZAlteredrr(r#z%6u | %s | %-16.16s | %s | %4uTrz%Y-%m-%d %H:%Mr'*#Errz%s%s )rXoldr)Zhistory_list_viewrcmdlinerloginuidrrr,r_rr+Z_real_term_widthr{r reversedrr r$strftime localtime beg_timestampr'rc return_codeZ is_outputaltered_lt_rpmdbaltered_gt_rpmdbtid)r.tidsreverse transactionsZuidsdoneZblanksrfmtrwZ real_colsZ name_widthZ table_widthZtmrZuiactsZrmarkZlmarkr#r#r$historyListCmdsp                 zOutput.historyListCmdcCst|}|jj}|dkr8tjtdtjjtd|j }|j }g}|sz|jjdd}|dk r|j |j |j |n |jj |}|stjtdtjjtdd \}} d} d} |rt|}|j\}} x|D]} |dk o| j |kr|jj} | jt| d}d}| j |krL| j | krL| dkr} t td | | |jdk r(|jrt td!|jdnt td!|jt|ttfrvt} xD|D],}|| krVqD| j|t td"|qDWnt td"|t|jttfr|j}|ddkrt td#dtd$d|dd}nHt|st td#td%n*|rnt td#td&d'jd(d|DnV|jdkr.Z InstalledZErasedUpgraded Downgraded)rBrorz Not installedZOlderZNewercSsg|] }t|qSr#)r)r8rr#r#r$r9zsmaxlenFrTc sd|}|r}n}|d}jjjj|jdj} | sH|d}nBjj| d} | r|j| } | dkrpn| dkr|d}n|d}|rj d\} } nj d \} } t ||d }d }|r|j }t d || || |t ||fdS) Nr'rB)rwrrrXrrFrGrYrz%s%s%s%s %-*s %s)rYrrZfiltermrwZrunrXpackageZcomparerPr rr{r)r|Z prefix_len was_installedrM pkg_max_lenZ show_reporlZ _pkg_statesstateZipkgsZinst_pkgresrNrOZui_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$r9szFailure:zReleasever :zCommand Line :zComment :zTransaction performed with:r)r[r\zPackages Altered:zScriptlet output:z%4dzErrors:)FFrTr[i,i,iPFi,iPFiiiiQ)"r>rIrrrrrrGrr{rrBr$r@rAZbeg_rpmdb_versionrDZ end_timestamprQrErnrrrCallrZ releaseverr=commentZperformed_withrhistoryInfoCmdPkgsAlteredoutputr)r.r<rTr>rwrYrarGZbegtZbegtmZendtZendtmrhseenrBZcodesr=rdZ perf_withZmax_lenZwith_pkgZstr_lenZt_outrlineZt_errr#)r_r`r.r$rSps   (             &                   zOutput._historyInfoCmdr z Dep-Install Obsoleted ObsoletingErase Reinstallr rWr rV) z True-Installr z Dep-Installrirjrkrlr rWZUpdateZUpdatedc s|j}d}d}|j}xH|D]@|jjj}|t|krDt|}tt}||kr|}qWx|D]d } jtjj krd} d} |rt fdd|Drd} |j | \} } |jjj}t t ||}td | | || |tjfqfWd 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'rz ** rGcsg|]}j|qSr#)r)r8Zpat)r|r#r$r9Bsz4Output.historyInfoCmdPkgsAltered..rFz%s%s%s%s %-*s %sNz )_history_state2uistaterr<r&rrr]rrZTransactionItemState_DONErrPr r r{r) r.r<rTZ all_uistatesrYr\rZuistateZpkg_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__rrecompilerr/r6rErPrS staticmethodrWpropertyrXrYr=rjrkr2rrrrrrrrrrrrrrrrrrrrrrrrr"r%r'rrLrrUrSrrmrer#r#r#r$r&Cs       /    V $N -  ' c / _2  " MM ' r&c@s(eZdZdZddZddZddZdS) r zGProvides text output callback functions for Dependency Solver callback.cCsd}|dkrtd}n||dkr(td}nj|dkr:td}nX|dkrLtd }nF|d kr^td }n4|d krptd }n"|dkrtd}n|dkrtd}|rtj||j|j|jdS)aPrint 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 erasedrz)---> 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)rrdebugrwrxry)r.r|moderfr#r#r$ pkg_addedPs&       z"DepSolveProgressCallBack.pkg_addedcCstjtddS)zRPerform setup at the beginning of the dependency solving process. z"--> Starting dependency resolutionN)rrvr)r.r#r#r$startyszDepSolveProgressCallBack.startcCstjtddS)zAOutput a message stating that dependency resolution has finished.z"--> Finished dependency resolutionN)rrvr)r.r#r#r$rpszDepSolveProgressCallBack.endN)rnrorprqrxryrpr#r#r#r$r Ms)r c@seZdZddZddZdS) CliKeyImportcCs||_||_dS)N)r*rf)r.r*rfr#r#r$r/szCliKeyImport.__init__cCsbdd}td|||tjj||jddf}tjd||jjj rJdS|jjj rXdS|j j S) NcSs$tjjr dnd}|ddjd|S)N00ri)rZpycompZPY3rjust)rZrjr#r#r$short_idsz'CliKeyImport._confirm..short_idzLImporting GPG key 0x%s: Userid : "%s" Fingerprint: %s From : %szfile://rz%sTF) rrZcryptoZ_printable_fingerprintrJrrNr*r)Z assumeyesZassumenorfr)r.rZuseridZ fingerprintrZ timestampr~ror#r#r$_confirms    zCliKeyImport._confirmN)rnrorpr/rr#r#r#r$rzsrzcsNeZdZdZeddZfddZddZdd Zd d Z dddZ Z S)CliTransactionDisplayz1A YUM specific callback class for RPM operations.cCs tjjjS)N)rr+r, _term_width)r.r#r#r$rszCliTransactionDisplay.cs0tt|jd|_d|_d|_d|_d|_dS)NrTr0rr)superrr/lastmsg lastpackagerfmarkmarks)r.) __class__r#r$r/s zCliTransactionDisplay.__init__c Csjtjjj|}|dkrdS|j}t|} ||_|dkr>d} n|td|} |j||||| || |dS)aOutput 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 Nrd) rrACTIONSr<_max_action_widthr rr _out_progress) r.rZrti_doneti_totalts_donets_totalZ action_strwid1pkgnamepercentr#r#r$r-s zCliTransactionDisplay.progresscCsHt|ds>d}x(tjjjD]}t|}||kr|}qW||_|j}|S)N_max_action_wid_cacher)hasattrrrrrr r)r.rrCZwid_valr#r#r$rs z'CliTransactionDisplay._max_action_widthc Cs|jrtjjs||kr|j|||tjj||d\} }} t|}| t|||t|| | f} | |jkrtj j d| tj| |_||krt ddS)N)r-rrZ write_flushr') rfrrisatty_makefmtr r rrr_terminal_messengerr{) r.rrrrrZprocessrrrKwid2ror#r#r$rs   z#CliTransactionDisplay._out_progressTNcCstt|}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 krd | }|}n|rD|d kr*||jt||d f}nd}d|d| }| }nL|d kr\d| }|}n4|d krx||j|f}nd}d|d| }| }|||fS)Nz%s.%s%zs/%srrrZrz[%-zs]rz %s: %s r gY@rz %s: %s r'z %s: %s z %s: %s )rrr rirr)r.rrrr-rrlrZfmt_donerJZpnlZoverheadrirZfmt_barZfull_pnlrKrZbarr#r#r$rsP            zCliTransactionDisplay._makefmt)TNr) rnrorprqrurir/r-rrr __classcell__r#r#)rr$rs    rc Csd}tjjsdS|dkr d}n|dkr6t||}nd}tjjj}|dkrZ||krZd}d||f}|t|d8}|dkrd}|dkr|d8}|dkrd}|t ||}d|||f}n||krd t ||||f}nb|d 8}|dkrd}|d} | t |krt |} || 8}|t ||}d t || | |||f}||krZtj j d |tj||krvtj j d d tjtj j dtjddS)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%srz %s: [%-*s]%swriterflush)r)rrrrrr+r,rrrr r rr) rTZtotalrwrrrirpZhashbarrfZnwidr#r#r$r!sL       r!)N)sb   (    7