grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a ©!c!0ã@sîddlmZddlmZddlmZddlZddlZddlZddlZddl Z ddl Z Gdd„de ƒZ dd„Z d d „Zd d „Zd d„Zdd„Zdd„Zdd„Zd'dd„Zdd„Zd(dd„Zd)dd„Zd d!„Zd"d#„Zd$d%„Zed&ƒ\ZZeZdS)*é)Úprint_function)Úunicode_literals)ÚunicodeNc@s$eZdZdd„Zdd„Zdd„ZdS)Ú UnicodeStreamcCs||_||_dS©N)ÚstreamÚencoding)Úselfrr©r ú,/usr/lib/python3.9/site-packages/dnf/i18n.pyÚ__init__$szUnicodeStream.__init__cCsžt|tƒs.tjjr | |jd¡n | |jd¡}z|j  |¡WnZt y˜| |jjd¡}t |jdƒrx|jj   |¡n| |jjd¡}|j  |¡Yn0dS)NÚreplaceÚbackslashreplaceÚbufferÚignore) Ú isinstanceÚstrÚdnfÚpycompÚPY3ÚdecoderÚencoderÚwriteÚUnicodeEncodeErrorÚhasattrr)r ÚsZs_bytesr r r r(s  ÿ  zUnicodeStream.writecCs t|j|ƒSr)Úgetattrr)r Únamer r r Ú __getattr__7szUnicodeStream.__getattr__N)Ú__name__Ú __module__Ú __qualname__r rrr r r r r#srcCs0|dur dS| ¡}| d¡s(| d¡r,dSdS)a‘Return true if encoding can express any Unicode character. Even if an encoding can express all accented letters in the given language, we can't generally settle for it in DNF since sometimes we output special characters like the registered trademark symbol (U+00AE) and surprisingly many national non-unicode encodings, including e.g. ASCII and ISO-8859-2, don't contain it. NFzutf-Zutf_T)ÚlowerÚ startswith)rr"r r r Ú_full_ucd_support:s r$cCst d¡}| d¡rdS|S)z= Take the best shot at the current system's string encoding. FZANSIzutf-8)ÚlocaleÚgetpreferredencodingr#)rr r r Ú_guess_encodingKs r'c Cs–ztj tjd¡Wn|tjy�ztj tjd¡dtjd<Wn.tjyptj tjd¡dtjd<Yn0td  tjd¡t j d�Yn0dS)NÚzC.UTF-8ÚLC_ALLÚCz&Failed to set locale, defaulting to {})Úfile) rrÚ setlocaler%r)ÚErrorÚosÚenvironÚprintÚformatÚsysÚstderrr r r r Ú setup_localePsÿr4cCs^tj}| ¡st tjtj¡z |j}Wnty>d}Yn0t|ƒsZt |t ƒƒt_dSdS)z½ Check that stdout is of suitable encoding and handle the situation if not. Returns True if stdout was of suitable encoding already and no changes were needed. NFT) r2ÚstdoutÚisattyÚsignalÚSIGPIPEÚSIG_DFLrÚAttributeErrorr$rr')r5rr r r Ú setup_stdout^s   r;cCst|dd�tj ¡S)z› It uses print instead of passing the prompt to raw_input. raw_input doesn't encode the passed string and the output goes into stderr r()Úend)r0rrZ raw_input)Zucstringr r r Ú ucd_inputrs r=cCs”tjjr:tj |¡r$t|tƒdd�St|tƒr2|St|ƒSt|tjjƒrL|St|dƒrxztj |¡WSt yvYn0tjjt|ƒtƒdd�SdS)zD Like the builtin unicode() but tries to use a reasonable encoding. r)ÚerrorsZ __unicode__N) rrrZ is_py3bytesrr'rrrÚ UnicodeError)Úobjr r r Úucd}s    rAcCst |¡dvrdSdS)N)ÚWÚFéé)Ú unicodedataZeast_asian_width)Zucharr r r Ú_exact_width_char˜srGcCsV|durt|ƒ|fSd}d}|D],}t|ƒ}|||kr<qN||7}||7}q ||fS)a' Return the textual width of a Unicode string, chopping it to a specified value. This is what you want to use instead of %.*s, as it does the "right" thing with regard to different Unicode character width Eg. "%.*s" % (10, msg) <= becomes => "%s" % (chop_str(msg, 10)) Nrr()Ú exact_widthrG)ÚmsgÚchopÚwidthZ chopped_msgÚcharZ char_widthr r r Úchop_strœs   rMcCstdd„|DƒƒS)zQ Calculates width of char at terminal screen (Asian char counts for two) css|]}t|ƒVqdSr)rG)Ú.0Úcr r r Ú ³ózexact_width..)Úsum)rIr r r rH°srHTr(cCsjt||ƒ\}}||kr0|s|rfd |||g¡}n6d||}|rTd ||||g¡}nd ||||g¡}|S)aµ Expand a msg to a specified "width" or chop to same. Expansion can be left or right. This is what you want to use instead of %*.*s, as it does the "right" thing with regard to different Unicode character width. prefix and suffix should be used for "invisible" bytes, like highlighting. Examples: ``"%-*.*s" % (10, 20, msg)`` becomes ``"%s" % (fill_exact_width(msg, 10, 20))``. ``"%20.10s" % (msg)`` becomes ``"%s" % (fill_exact_width(msg, 20, 10, left=False))``. ``"%s%.10s%s" % (pre, msg, suf)`` becomes ``"%s" % (fill_exact_width(msg, 0, 10, prefix=pre, suffix=suf))``. r(ú )rMÚjoin)rIÚfillrJÚleftÚprefixÚsuffixrKZextrar r r Úfill_exact_width¶s rYéFcsćfdd„‰| d¡}| dd¡ d¡}g}|}d}d}d} |D�]`} |  d¡} || } } ˆ| ƒ\}} d} |rv| rvd } |rŠ|t| ƒkrŠd } |r¦| s¦|d kr¦|| kr¦d } | rÂ| | d¡¡|}d}|t| ƒkrÒd } |rä|  d¡} | } t|| ƒ|k�rd}| || ¡|}q@d }|  d¡}|} | }|�s8|d k�r8|}|D]V}|t| |ƒk�r€t| ƒt|ƒk�r€| |  d¡¡|d|} | |7} | d7} �q<|  d¡d}q@|�rº| | d¡¡d |¡S) zq Works like we want textwrap.wrap() to work, uses Unicode strings and doesn't screw up lists/blocks/etc. cs˜d}d}|D]}|dkrq&|d7}q |dvr6|dfSt||d…dƒd}|dvr�ˆ||t|ƒd…ƒ}|dpz|d}|r�||d|fS|dfS)NrÚXrSrE)ú-Ú*Ú.Úoõâ)r\r]r^r_u•u‣u∘)rMÚlen)ÚlineÚcountZbyteZlist_chrZnxt©Ú_indent_at_begr r reÜs z%textwrap_fill.._indent_at_begÚ ú z FrrSTér()Úrstripr ÚsplitraÚappendÚlstriprHrT)ÚtextrKÚinitial_indentÚsubsequent_indentÚlinesÚretÚindentZ wrap_lastZcsabZ cspc_indentrbZlsabZ lspc_indentZforce_nlÚwordsZspcsZwordr rdr Ú textwrap_fillØsh         ÿ  rtcCsHt|ƒ}t|ƒ}||kr|S||kr4||kr0|S|S||kr@|S|SdS)aÐ Automatically selects the short (abbreviated) or long (full) message depending on whether we have enough screen space to display the full message or not. If a caller by mistake passes a long string as msg_short and a short string as a msg_long this function recognizes the mistake and swaps the arguments. This function is especially useful in the i18n context when you cannot predict how long are the translated messages. Limitations: 1. If msg_short is longer than width you will still get an overflow. This function does not abbreviate the string. 2. You are not obliged to provide an actually abbreviated string, it is perfectly correct to pass the same string twice if you don't want any abbreviation. However, if you provide two different strings but having the same width this function is unable to recognize which one is correct and you should assume that it is unpredictable which one is returned. Example: ``select_short_long (10, _("Repo"), _("Repository"))`` will return "Repository" in English but the results in other languages may be different. N)rH)rKZ msg_shortZmsg_longZ width_shortZ width_longr r r Úselect_short_long'srucCs2tƒdd„}tjjj|dd�}t|tj |¡ƒS)z< Easy gettext translations setup based on given domain name cs ‡fdd„S)Ncs tˆ|ŽƒSr)rA)Úw©Zfncr r ÚTrQz2translation..ucd_wrapper..r rwr rwr Ú ucd_wrapperSsz translation..ucd_wrapperT)Úfallback)r4rrÚgettextÚ translationÚmapZ gettext_setup)rryÚtr r r r|Nsr|cCs(t|tdƒ|ƒ}d|vr |S|SdS)Nrhú)Ú_Úchr)ÚcontextÚmessageÚresultr r r ÚpgettextYsr…r)N)NTr(r()rZr(r()Z __future__rrZ dnf.pycomprrr%r.r7r2rFÚobjectrr$r'r4r;r=rArGrMrHrYrtrur|r…r€ZP_ZC_r r r r Ús2      " O'