1 # ˆl–äY>”Ð?Jq@¿q§®2ú˜´oÀ ƒ}Æ›¿ÄÃ%­ a ©!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 Un