a 2h\@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 0d 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)MergedTransactionWrapperdnfcCstt|ftd}t|}|d}| |}|s@td|}n|rR|d|t|}tt|g|g|RS)Nr) itertoolschainrepeatlenextenditerlistzip)Z cols_countZlabellstleftZ lst_lengthZ right_countZ missing_itemsZlst_iterr$2/usr/lib/python3.9/site-packages/dnf/cli/output.py_spread_in_columns6s r&c @s eZdZdZdZedZddZddZ dd Z d d Z d d Z e ddZeddZeddZdlddZe ddZddZdmddZdnd d!Zdod"d#Zd$d%Zd&d'Zd(d)Zdpd+d,Zdqd-d.Zdrd/d0Zidifd1d2Zdsd3d4Zd5d6Z d7d8Z!d9d:Z"d;d<Z#d=d>Z$d?d@Z%dtdAdBZ&dudCdDZ'dvdEdFZ(dGdHZ)dIdJZ*dwdKdLZ+dMdNZ,dOdPZ-dQdRZ.dSdTZ/dUdVZ0dxdWdXZ1dydYdZZ2ge3fd[d\Z4gfd]d^Z5e6d_e6d_e6d`e6dae6dbe6dce6dde6dee6dfe6dge6dhdi Z7gfdjdkZ8dS)zOutputz+Main output class for the yum command line.z z ^\*{0,2}/cCs$||_||_tjj|_d|_dSN)confbaserclitermZTermprogress)selfr*r)r$r$r%__init__IszOutput.__init__cCs0|jj}dd|}|t||d}|||fS)N%s= )r,columns fmtColumnsr!)r.col_datarowZ term_widthZruleheaderr$r$r%_bannerOs zOutput._bannerc Csrdd|dD}|D]:}t|D],\}}||}t|}||dd||<q"q|j|ddd}tttj|S)NcSsg|] }tqSr$)dict).0rr$r$r% Vz&Output._col_widths..rr )indent) enumeraterget calcColumnsr mapoperatorneg) r.rowsr5r6ivalZcol_dctlengthcolsr$r$r% _col_widthsUszOutput._col_widthscCs d}d}|snt|tr |dkr.|jjd}n|dkr8n|ddD]}|dkrZd}qH||jjvrx||jj|7}qH||jjvr||jj|7}qH|dr|dd|jjvr||jj|dd7}qH|drH|dd|jjvrH||jj|dd7}qH|r|jjd}||fS) Nrboldnormal,r2zfg:zbg:) isinstancerr,ZMODEreplacesplitZFG_COLOR startswithZBG_COLOR)r. highlighthibeghiendZhighr$r$r% _highlight`s4     zOutput._highlightcKs(||\}}|jj||||fi|Sr()rVr,sub)r.ZhaystackrSZneedleskwdsrTrUr$r$r%_sub_highlight}szOutput._sub_highlightcCs2d}|D]$}||d|kr q.||d7}q|S)z; Spaces left on the current field will help how many pkgs? rrr$)currentZ data_tupsr#rettupr$r$r%_calc_columns_spaces_helpss z!Output._calc_columns_spaces_helpscCs|jjSr()r*historyr.r$r$r%r^szOutput.historycCs|jjSr()r*sackr_r$r$r%r`sz Output.sackNrrcCst|}|}dg|}td|D]}t||||<q |durJ|jj}|durjdg|d}|d|sg} td|D]6}||} | r| | ddq|| ||dq|| dt|7<|jj} t | | kr| S| }|t ||dt |8}|ds|d7}|dkrd} d} td|D]b}| |||||}|sRq.| rx||dkrx|d| krxq.|| krq.|} |} q.| r||  dd|| }|| s| |dkr|d8}|| |7<||8}qd}td|D]}||sq|d7}q|r`||}td|D],}||sDq2|||7<||8}q2|d8}||}td|D]}|||7<qz|||||7<d}q|S)aDynamically 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) rrangesorteditemsr, real_columnsappendrr3sumr r]pop)r.datar3remainder_column total_widthr>rIZpdatadZ full_columnscolZ default_widthZhelpsrGZthelpsdiffZoverflowed_columnsZnormr$r$r%rAs      "     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|dksJt|dkr8|\}}d}}t|dkr\|\}}}||\}}t||||fS)NrbrNr)rrVr )r.r5rGrprTrUrSr$r$r% _col_datas   zOutput._col_datac CsBt|}t|}g}|ddD]}||\}}} } |sN|d7}||q ||\} }t|} | |kr|d7}| r|| |d|| | gq|| d|| || gn(|dd||d7}|| || g||7}|d7}q ||d\}}} } ||\} }t||| | | d}|d |7}|||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 Nrar0z %s%s%s%s r2z%s%s%s r)r#prefixsuffixz%%s%s) r rrrrgrqr rr tuple) r.r3msgendrlrjr5rGrprTrUZ align_leftZ val_widthr$r$r%r4%s8     zOutput.fmtColumnsFcCsP|dur d}d||j|jf}|ddg}t||j|jf||}t||dS)aPrint 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)iiz%s%s.%srL)namearchr!evr _from_repoprintr4)r.pkg ui_overflowr>rSr3Znahi_colsr$r$r% simpleListTs  zOutput.simpleListc CsN|dur d}d|t|f}|ddg}|j}t||f||}t||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)irx%s%srL)r ui_from_repor!r}r4) r.r~rr>rSr3ZenvrarZridr$r$r%simpleEnvraListjs zOutput.simpleEnvraListcCstt|jdS)z.Print a package as a line containing its name.N)r}r ryr.r~r$r$r%simple_name_listszOutput.simple_name_listcCstt|dS)z/Print a package as a line containing its NEVRA.N)r}r rr$r$r%simple_nevra_listszOutput.simple_nevra_listcCst|}|jj}|st}n |dkr&d}d|dd}|s>|St|}t||||d}|ddkr||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 r2rbz: )rpinitial_indentsubsequent_indent rrNz ...: )r r,rfrr r count)r.keyrGZkeylenrIZnxtr[r$r$r% fmtKeyValFills$zOutput.fmtKeyValFillr1cCsht|}|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 rbz%s %s %s)r r,r3r r)r.ryfillrIZname_lenZbegrwr$r$r% fmtSections   zOutput.fmtSectionc sdd}fdd}g}|\}}tdtddtdd}|||d ||j|f|jrv||td |jtdtdd tdd }||||j||td |jtdtdd tdd}||||j tdtddtdd}|||t t |j ||td|j tdtddtdd}||||j|jrj|} | r||td| jjr<||td|j||tdtj|j|jr||tdtj|jj|} | r.format_key_valcst|ddd|pdS)Nrz : r)rr rr_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)&rVrrrgryZepochrversionreleaserzrfloat_sizeZ sourcerpmrepoid _from_systemr^Zrepor)verboseZpackagerrutilZnormalize_timeZ buildtimeZ installtimeZ package_dataint_itemZgetInstalledBy ValueError_pwd_ui_usernamesummaryurlr license descriptionr) r.r~rSrrZ output_listrTrUrZ history_repoZ history_pkguidr$r_r% infoOutputs|                zOutput.infoOutputc Cs|\}}|durV|jj}|jtjkr,|jj}|j|||d|j||d|jjddS|}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)r3rS )r3r>rS%s.%sz%-35.35s [%.12s] %.10s %-20.20s) r)color_update_remotereponamehawkeyZSYSTEM_REPO_NAMEcolor_update_localrcolor_update_installedZ compactPrintryrzrr}) r.ZuotupZ changetyper3Z changePkgZinstPkgZchiZ c_compactZ i_compactZc_repor$r$r%updatesObsoletesLists    zOutput.updatesObsoletesListc Csd|dvr`t|dkrXtd|t}|dkr^i}|D]} | |t| t| j<q:|}t|D]} | j| jf} d} | |vr| dd} nD| || r| dd} n(| || r| d d } n | d d} |dkr|j | d | |d qf|dkr| |j| | ddqf|dkr*|| qf|dkrf|| qfqf|rXtdt|t|SdS)aPrints 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 inforynevrarr0r Fznot inrLr1>rK||vr>||d||<q>|SNrr) r`query installedZ _name_dict availablerrr r!)r.sectionsrrrmpkg_namer$r$r%_pkgs2name_dictszOutput._pkgs2name_dictc Csi}i}tjtt|dD]d}||}|dur6qtt|t|j}tt|j}||dd||<||dd||<q||fSr) rrr r!r@r r GRP_PACKAGE_INDENTr) r.r name_dictZ nevra_lengthsZ repo_lengthsrr~Znevra_lZrepo_lr$r$r%_pkgs2col_lengthss zOutput._pkgs2col_lengthscCs |D]}td|j|fqdS)Nr)r}r)r. pkg_namesryr$r$r%_display_packagesszOutput._display_packagesc Csl|D]b}z ||}Wn(ty<td|j|fYqYn0d}|jsP|jj}|j|d|j||dqdS)NrFT)rr>rSr3)KeyErrorr}rrr)Zcolor_list_available_installr)r.rrr3ryr~rSr$r$r%_display_packages_verboses   z Output._display_packages_verbosec Cshdd}ttdtj|j|jj}|rDttdt|j |j rdttdt|j p`d|j r|ttd|j td||j ftd ||j ftd ||jftd ||jff}|r0||}|||}||}|d  |d  f}|D].\}} t| d krqt||| ||qn4|D].\}} t| d krNq4t||| q4dS)zOutput information about the packages in a given group :param group: a Group object to output information about cSstdd|DS)Ncss|]}tj|jVqdSr(rr_name_unset_wrapperryr:r~r$r$r% r<z?Output.display_pkgs_in_groups..names..rd)packagesr$r$r%namessz,Output.display_pkgs_in_groups..namesz Group: %sz Group-Id: %s Description: %srz Language: %sz Mandatory Packages:z Default Packages:z Optional Packages:z Conditional Packages:rrN)r}rrrrui_namer)rr idui_descriptionZ lang_onlyZmandatory_packagesZdefault_packagesZoptional_packagesZconditional_packagesrrrArrr) r.grouprrrrZ col_lengthsr3 section_namerr$r$r%display_pkgs_in_groupss:     zOutput.display_pkgs_in_groupscCsdd}ttdtj|j|jjr@ttdt|j |j rdt|j pRd}ttd|td||j ftd||j ff}|D](\}}t |d krqt|||qd S) zOutput information about the packages in a given environment :param environment: an Environment object to output information about cSstdd|DS)Ncss|]}tj|jVqdSr(r)r:rr$r$r%r r<zFOutput.display_groups_in_environment..names..r)groupsr$r$r%rsz3Output.display_groups_in_environment..nameszEnvironment Group: %sz Environment-Id: %srrz Mandatory Groups:z Optional Groups:rN)r}rrrrrr)rr rrZmandatory_groupsZoptional_groupsrr)r.Z environmentrrrrrr$r$r%display_groups_in_environments  z$Output.display_groups_in_environmentcsHdfdd fdd}jjr4d}ndjjf}|jpRd}r|d urjjjj|d d }t||d urjj }|sd Stt d j d}d} t |D]F} j| krd } qj | krt d } | | |d dd }qj| kr(t d} | | |ddd }qj| krRt d} | | |ddd }q|| |rdd }qt d} jD]} t| } t| | r| | |ddd }n`| d} t dtfdd| Dr| d}n| }t| |rr| | |ddd }qrqt|| gs>t |D]} t d} | | |ddqtd 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}|rTt||n t||dS)Nz Matched from:rTZ ignore_case)r}rr rYr)ritemZprinted_headline can_overflow)rSmatchforr.r$r%print_highlighted_key_item's  z8Output.matchcallback..print_highlighted_key_itemcsPj|sdStd}d}jD](}t||r"|||p>|ddd}q"|S)NFzFilename : %srT)FILE_PROVIDE_REmatchrfilesfnmatch)r printed_matchrZ file_matchfilename)porr.r$r%print_file_provides4s    z1Output.matchcallback..print_file_providesz%s : z%s.%s : rNTrzRepo : %szDescription : rzURL : %szLicense : %szProvide : %srz=<>c3s|]}|vVqdSr(r$)r:char)possibler$r%rpr<z'Output.matchcallback..zOther : %s)F)r)ZshowdupesfromreposryrzrrZcolor_search_matchrYr}rrrrrrrZprovidesrrrQany)r.rrrrrSrrvrZ name_matchrrZprovideZ first_provideZitem_newr$)rSrrrrr.r% matchcallbacksr             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}|D]}zpt|j}||7}z|r>||7}WntyRYn0|s\Wqzt|j}Wnty|Yn0||7}Wqtyd}td} t| YqYq0q|s|rttdt |||krttdt |||rttdt |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~sizervr$r$r%reportDownloadSizesH          zOutput.reportDownloadSizec Cspd}d}|D]F}z|j}||7}Wq tyPd}td}t|YqTYq 0q |slttdt|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~rrvr$r$r%reportRemoveSizes   zOutput.reportRemoveSizec Cs|sdSg}g}|jr$|td|jD]@}t||}||}|rP|jn|} |tdd| |q*|j r|td|j D]6}t| |}|j |j} |tdd| |q|r| |} |D]} ||t| | dq|| tdtdddf|d d <d |S) Nz+Marking packages as installed by the group:r@z)Marking packages as removed by the group:r2ZGroupPackagesrrr)Z new_groupsrgrr Zadded_packagesZ _group_by_idrrr&Zremoved_groupsZremoved_packagesrr@rJr4r!r8r) r.compsr^rooutrEZgrp_idZpkgsZ group_objectZgrp_namer5r6r$r$r%list_group_transactions.    $zOutput.list_group_transactioncQ sz tjtjBtjBtjBtjBtjB}t}t}|durt d} g}|D]:\}}t+|D]&}|&d||fddddddfqq|&| |ft!t'j j(,*}|rt d} g}|D]:\}}t+|D]&}|&d||fddddddfq|ql|&| |ft!t'j j(-*}|rt d} g}|D]"\}}|&|d|ddddfq|&| |ft!t'j j(.*}|rt d} g}|D]2\}}|&|dd|d|dfddddfqD|&| |ft!t+j j(/}|rt d} g}|D]}|&|ddddddfq|&| |ft!t+j j(0}|r6t d} g}|D]}|&|ddddddfq|&| |fj j1rdd }j j1j2j3}|rt d!} g}|4D]}|&||qn|&| |fj j1j2j5} | rt d"} g}| 4D]}|&||q|&| |fj j1j2j6}!|!r&t d#} g}|!4D]}|&||q|&| |fj j1j7j3}"|"rpt d$} g}|"4D]}|&||qL|&| |fj j1j7j5}#|#rt d%} g}|#4D]}|&||q|&| |fj j1j7j6}$|$rt d&} g}|$4D]}|&||q|&| |fj8j9rj8j:s,j j;j<|@r,g}j j=d'|d(\}}t'd)d*|D}t!|D]}%| ||| |%g} qZd+g}&j j>s|&&d,t d-d.?|&}'d/d0|D}|&|'|fg}t!|*D]\}(}%| ||| |%g} qt d1}'j j8j@r|'d}'n |'t d2}'d3d0|D}|&|'|fjAjB})|d4srj j(Csrj j1rnj j1j7srj j1j2srdS|d4i|d5|d6ig}d| ddd7g}*jD|d8|*d9|d:}*|*\}+} },}-}.tE|*d7}/|)|/kr|)n|/})tF|+td;d<td=d<}0tF| td;d>td=d?}1tF|,td;d@td=d@}2tF|-td;dAtd=dB}3tF|.td;dCtd=dC}4dDdE|)G|0|+ f|1| f|2|, f|3|- f|4|.ffd.dE|)fg}5|D]\} }|rdF| }6|D]\}7}8}9}:};}<}=|7|+ |=f|8| f|9|, f|:|- f|;|.ff}*G|*d.dG}>Hj8jI\}?}@t!|<D]6}AdHt dIdJ}B|B|?|AjJ|@|AjK|AjLf;}B|>|B7}> q|6|>}6q|r|5&|6q|5&t dKdE|)t dLtM|jtM|jtM|jtM|jdft dMtM|jdft dNtM|jtM|jtM|jdft dOtM|jdft dPtM|tM|dff}Cd}Dd}Ed}Fd}G|CD]\} }H}I|H sN|I sN q4tNd|5&|>|P|E|HdU|F|Jf|G|I|Ofn$dV}>|5&|>|P|E|Fd.|G|I|Ofn&|H rdW}>|5&|>tR| |D|E|H|Jf qd?|5S)Xz]Return a string representation of the transaction in an easy-to-read format. N)rvrrc s|j\}}}}} |j} |j} t|j} |dur2d}|jrBjj} n|jrRjj } njj } | ||| | | || fdt |fdt | fdt | ffD],\}}|| |d|||d7<qt|t |}|S)NZnoarchrrr rr)Zpkgtupr{r|rrrr)rZ _from_cmdlinerrrgr setdefaultmax)linesrja_widr obsoletesraerr r{rrhirmr_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|jSr(r~)xr$r$r%4r<z)Output.list_transaction..)rzInstalling module profilesz%s/%srzDisabling module profileszEnabling module streamszSwitching module streamsz%s -> %srzDisabling moduleszResetting modulescSstj|ddddddfS)Nr)rrrgetName)rr$r$r% format_lineqsz,Output.list_transaction..format_linezInstalling Environment GroupszUpgrading Environment GroupszRemoving Environment GroupszInstalling GroupszUpgrading GroupszRemoving GroupsT)Zreport_problems transactioncss|]}t||fVqdSr(rrr$r$r%rr<z*Output.list_transaction..z--bestz--allowerasingzSSkipping packages with conflicts: (add '%s' to command line to force their upgrade)r2cSsg|]}|dddqSNrarr$r:rFr$r$r%r;r<z+Output.list_transaction..z,Skipping packages with broken dependencies%sz or part of a groupcSsg|]}|dddqSrr$rr$r$r%r;r<rrr r=rb)r>r3rkrlrZPackagerrrrrrrz %s %s %s r1z%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 )SrZUPGRADEZ UPGRADE_ALLZ DISTUPGRADEZDISTUPGRADE_ALLZ DOWNGRADEZINSTALLrrrZ _make_listsr*Z WITH_MODULESrrrZupgradedZ reinstalledZinstalled_groupZ installed_depZinstalled_weakZerasedZ erased_depZ erased_cleanZ downgradedactionlibdnfrZTransactionItemAction_OBSOLETEDrZ getReplacedByr rrdZFORWARD_ACTIONSZTransactionItemAction_REMOVEr@r~rgr9Z_moduleContainerZgetInstalledProfilesrer ZgetRemovedProfilesZgetEnabledStreamsZgetSwitchedStreamsZgetDisabledModulesZgetResetModulesZ_historyenvZ _installedrZ _upgradedZ_removedrr)ZbeststrictZ_goalactionsZ_skipped_packagesZ_allow_erasingrZupgrade_group_objects_upgrader,r3Z isChangedrArhrr4rVrryrzr{rr r rr r )Qr.rrlZforward_actionsZskipped_conflictsZskipped_brokenZ list_bunchZ pkglist_linesrjr rZ ins_group_msgr Zpkglistr ZreplacestsirFZ obsoletedZinstalledProfilesryZprofilesZprofileZremovedProfilesZenabledStreamsstreamZswitchedStreamsZdisabledModulesZ resetModulesrZinstall_env_grouprZupgrade_env_groupZremove_env_groupZ install_groupZ upgrade_groupZ remove_groupr~ZrecommendationsZskip_strrZ output_widthr3Zn_widZv_widZr_widZs_widZ real_widthZ msg_packageZmsg_archZ msg_versionZmsg_repositoryZmsg_sizerZtotalmsgrrr{rrrrrvrTrUZobspoZappendedZ 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_transactions8          (  (  ,             $                              zOutput.list_transactionc sfdd}|sdSg}g}|d||D]}|t|q0dD]}|||}|rHq`qH|stjjd g}|r|dt|} |dt| ||t|d}qt|S)Ncst||krgSjj|dd}|dkr0gSdg|}d}|D]\}t|||krt|||}||krvgS||8}t|||<|d7}|t|;}qBtt|D](}||||7<||d9<q|S)zb Work out how many columns we can use to display stuff, in the post trans output. rrbrra)rr,r3rc)msgsnumr#Zcol_lensrnrvror_r$r% _fits_in_colsJs(   z+Output._pto_callback.._fits_in_colsrz{}:)rrrNrbrbz {})rgformatrr,r3rr4r!) r.r Ztsisr*rr(r%r)rIZ current_msgsr$r_r% _pto_callbackGs&  zOutput._pto_callbackcCstj|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_outputyszOutput.post_transaction_outputcCs@d}|jjdkr6tjjjtjd}tjjjtjd|_|tfS)z_Set up the progress callbacks and various output bars based on debug level. Nrb)fo) r)Z debuglevelrr+r-ZMultiFileProgressMetersysstdoutDepSolveProgressCallBack)r. progressbarr$r$r%setup_progress_callbackss  zOutput.setup_progress_callbackscCsz|dkr dS|jj}td|tdt|}dt||t|t|f}tt d|t ||}t|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,r3rrr timerrr rr)r.Z remote_sizeZdownload_start_timestamprpZdl_timervr$r$r%download_callback_total_cbs z!Output.download_callback_total_cbcCst}t}d}|D]<}|jtjjtjjfvr0q||j||j|d7}qt |dkrp|d t |fS|d t |fS)Nrr, r) rr r!rZTransactionItemAction_UPGRADEDZ TransactionItemAction_DOWNGRADEDr action_nameZ action_shortrrrdr )r.Zhpkgsr$Z actions_shortrr~r$r$r%_history_uiactionss    zOutput._history_uiactionsc st|trfdd|DS|dus.|dvrftd}tdd|}dur^t|kr^|}t|Sdd}zttt|}|t|jd d }t|j }d ||f}durt|krd |||f}t|krd |}|WSt yt|YS0dS)Ncsg|]}|qSr$r)r:ulimitr.r$r%r;r<z+Output._pwd_ui_username..)lizZSystemr2cWs|j|}|sdS|dS)zf Split gives us a [0] for everything _but_ '', this function returns '' in that case. rr)rQ)textargsr[r$r$r% _safe_split_0s z.Output._pwd_ui_username.._safe_split_0;rbz%s <%s>z %s ... <%s>z<%s>) rOr rrr pwdgetpwuidrpw_gecospw_namer) r.rr@ZloginidryrCuserfullnameZ user_namer$r?r%rs*    zOutput._pwd_ui_usernamec Csr|j|}|jjdkr"ddg}nb|jjdkr6dg}nN|jjdksFJt}d}d}|D]*}|d7}|jdurv|d7}||jqXd}t|dkrt d } |j j } | durt j j d} | durd } | d kr| d nd } n t d } d } t|tt dddt| | | tt dddtt dddtt dddfd| dddddd} td| d}|durxt|}|D]}t|dkr|jpd} n||jd } t| } tdt|j} ||\}}t| | | } t|dd}d}}|jdurd}}n"|jr d}}n|jr0d }}|jr.Z InstalledZErasedUpgraded Downgraded)rFrorz Not installedZOlderZNewercSsg|] }t|qSr$)r)r:rr$r$r%r;yr<maxlenFrTc sd|}|r}n}|d}jj|jd} | sH|d}nBj| d} | r|| } | dkrpn| dkr|d}n|d}|r d\} } n d \} } t ||d }d }|r| }t d || || |t ||fdS) Nr2rF)ryrrrprrKrLrqr%s%s%s%s %-*s %s)r`rrZfiltermryrunr^packageZcomparerVr rr}r)r~ prefix_len was_installedrS pkg_max_lenZ show_reporsZ _pkg_statesstateZipkgsZinst_pkgresrTrUZui_repo)_pkg_states_available_pkg_states_installedr.r$r% _simple_pkg}s4     z+Output._historyInfoCmd.._simple_pkgrzTransaction ID :z%u..%uraz%czBegin time :zBegin rpmdb :z**i,z (%u seconds)iPFz (%u minutes)<iz (%u hours)iz (%u days)iQzEnd time :zEnd rpmdb :zUser :zReturn-Code :ZAbortedZSuccessz Failures:r:cSsg|] }t|qSr$rrr$r$r%r;r<zFailure:zReleasever :zCommand Line :cs>jtjjkrd}njtjjkr(d}nd}ttd|dS)NZPersistZ TransientZUnknownzPersistence :) persistencer!rZTransactionPersistence_PERSISTZ TransactionPersistence_TRANSIENTr}r)r~Zpersistence_str)rTr$r%print_persistences z1Output._historyInfoCmd..print_persistencezComment :zTransaction performed with:r)rvrwzPackages Altered:zScriptlet output:z%4dzErrors:)FFrT)#rVrOrrr r rr_rr}rrZr8rXrYZbeg_rpmdb_versionr\Z end_timestamprir]rurrr[allrZ releaseverrUr~commentZperformed_withrhistoryInfoCmdPkgsAlteredoutputr)r.rTrlrVryrqr|r_ZbegtZbegtmZendtZendtmroseenrFZcodesrUrr~rZ perf_withZmax_lenZwith_pkgZstr_lenZt_outr)lineZt_errr$)rzr{rTr.r%rkos      )            &                 zOutput._historyInfoCmdr Dep-Install Obsoleted ObsoletingErase Reinstallrrorrn) z True-InstallrrrrrrrroZUpdateZUpdatedc s|j}d}d}|}|D]@|jj}|t|krBt|}tt}||kr|}q|D]d} jtjj krzd} d} |rt fdd|Drd} | | \} } |jj}t t ||}td| | || |tfq`d 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 rrz ** rLcsg|]}|qSr$)r)r:patrr$r%r;Or<z4Output.historyInfoCmdPkgsAltered..rKrrN)_history_state2uistaterr@r;rrrxr!rZTransactionItemState_DONErrVr r r}r) r.rTrlZ all_uistatesrqrwrZuistateZpkg_lenrsrSrTrUr$rr%r/s4    z Output.historyInfoCmdPkgsAltered)NrNr)rr)FrFN)FrFN)r1)F)N)NN)NNN)N)F)N)N)F)9__name__ __module__ __qualname____doc__rrecompilerr/r8rJrVrY staticmethodr]propertyr^r`rArqrrr4rrrrrrrrrrrrrrrrrrrrrr'r/r0r6r9r<rrdrrmrkrrrr$r$r$r%r'Cs        /    V $ O -  ' d / ^2  " MM 5 r'c@s(eZdZdZddZddZddZdS) r4zGProvides 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}|rt||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 NrFz'---> 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 reinstalledrmz)---> Package %s.%s %s will be a downgraderpz(---> Package %s.%s %s will be obsoletingZudz&---> Package %s.%s %s will be upgradedZodz'---> Package %s.%s %s will be obsoleted)rrdebugryrzr{)r.r~moderr$r$r% pkg_added]s&       z"DepSolveProgressCallBack.pkg_addedcCsttddS)zRPerform setup at the beginning of the dependency solving process. z"--> Starting dependency resolutionNrrrr_r$r$r%startszDepSolveProgressCallBack.startcCsttddS)zAOutput a message stating that dependency resolution has finished.z"--> Finished dependency resolutionNrr_r$r$r%rwszDepSolveProgressCallBack.endN)rrrrrrrwr$r$r$r%r4Zs)r4c@seZdZddZddZdS) CliKeyImportcCs||_||_dSr()r*r)r.r*rr$r$r%r/szCliKeyImport.__init__cCsbdd}td|||tj||ddf}td||jjj rJdS|jjj rXdS|j S) NcSs$tjjr dnd}|ddd|S)N00ir+)rZpycompZPY3rjust)rZrjr$r$r%short_idsz'CliKeyImport._confirm..short_idzLImporting GPG key 0x%s: Userid : "%s" Fingerprint: %s From : %szfile://rr0TF) rrZcryptoZ_printable_fingerprintrPrrfr*r)Z assumeyesZassumenorr)r.rZuseridZ fingerprintrZ timestamprrvr$r$r%_confirms     zCliKeyImport._confirmN)rrrr/rr$r$r$r%rsrcsNeZdZdZeddZfddZddZdd Zd d Z dddZ Z S)CliTransactionDisplayz1A YUM specific callback class for RPM operations.cCs tjjSr()rr+r, _term_widthr_r$r$r%rr<zCliTransactionDisplay.cs0tt|d|_d|_d|_d|_d|_dS)NrTr1)superrr/lastmsg lastpackagermarkmarksr_ __class__r$r%r/s zCliTransactionDisplay.__init__c Csjtjj|}|durdS|}t|} ||_|dkr>d} n|td|} |||||| || |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.rtr ti_doneti_totalts_donets_totalZ action_strwid1pkgnamepercentr$r$r%r-s zCliTransactionDisplay.progresscCsDt|ds:d}tjjD]}t|}||kr|}q||_|j}|S)N_max_action_wid_cacher)hasattrrrrrr r)r.rrGZwid_valr$r$r%rs z'CliTransactionDisplay._max_action_widthc Cs|jrtjs||kr|j|||tj||d\} }} t|}| t|||t|| | f} | |jkrtj d| tj| |_||krt ddS)N)r-rrZ write_flushr2) rr2r3isatty_makefmtr r rrr_terminal_messengerr}) r.rrrrrZprocessrrrcwid2rvr$r$r%rs     z#CliTransactionDisplay._out_progressTNcCstt|}d||f}d|d|d} | ||f} |durFd} 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)Nr%zs/%srrbrz[%-zs]rz %s: %s rgY@rz %s: %s r2z %s: %s z %s: %s )rrr rprr)r.rrrr-rrlrZfmt_donerbZpnlZoverheadrprZfmt_barZfull_pnlrcrZbarr$r$r%rsP            zCliTransactionDisplay._makefmt)TNr) rrrrrrpr/r-rrr __classcell__r$r$rr%rs    rc Csd}tjsdS|dkr d}n|dkr6t||}nd}tjj}|durZ||krZd}d||f}|t|d8}|dkrd}|dur|d8}|dkrd}|t ||}d|||f}n||krd t ||||f}nb|d 8}|dkrd}|d} | t |krt |} || 8}|t ||}d t || | |||f}||krZtj d |tj||krvtj 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 rRNrr7z %d/%drrbz [%-*s]%sz %s%srz %s: [%-*s]%swriterflush)r)r2r3rrrr+r,rrrr r rr) rZtotalryrrrprwZhashbarrZnwidr$r$r%r5+sN      r5)N)sb   (    %7