a !c!0 @ s d dl mZ d dl mZ d dlmZ d dlZd dlZd dlZd dlZd dl Z d dl Z G dd deZdd Z d d Zdd Zd d Zdd Zdd Zdd Zd'ddZdd Zd(ddZd)ddZd d! Zd"d# Zd$d% Zed&\ZZeZdS )* )print_function)unicode_literals)unicodeNc @ s$ e Zd Zdd Zdd Zdd ZdS ) UnicodeStreamc C s || _ || _d S N)streamencoding)selfr r r ,/usr/lib/python3.9/site-packages/dnf/i18n.py__init__$ s zUnicodeStream.__init__c C s t |ts.tjjr || jdn|| jd}z| j | W nZ t y || jjd}t| jdrx| jj | n|| jjd}| j | Y n0 d S )Nreplacebackslashreplacebufferignore) isinstancestrdnfpycompPY3decoder encoder writeUnicodeEncodeErrorhasattrr )r sZs_bytesr r r r ( s zUnicodeStream.writec C s t | j|S r )getattrr )r namer r r __getattr__7 s zUnicodeStream.__getattr__N)__name__ __module____qualname__r r r r r r r r # s r c C s0 | du rdS | }|ds(|dr,dS dS )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)r r" r r r _full_ucd_support: s r$ c C s t d} | drdS | S )z= Take the best shot at the current system's string encoding. FZANSIzutf-8)localegetpreferredencodingr# )r r r r _guess_encodingK s r' c C s zt jtjd W n| tjy zt jtjd dtjd<