VULN_CHECK_I913V6 (fZ9zddlmZddlmZddlZddlZddlZddlZddlZddl Z ddl Z ddZ ddZ Gdde Zy) )absolute_import)unicode_literalsNc d}tj|tj|}t j d|d}|S#t $rYywxYw)z Get the real terminal width abcdefghshhhhN)fcntlioctltermios TIOCGWINSZstructunpackIOError)fdbufrets 1/usr/lib/python3.12/site-packages/dnf/cli/term.py_real_term_widthrsPkk"g00#6mmGS)!, sAA AAc0td}|sy|dkry|S)z@ Compute terminal width falling to default 80 in case of troublerrPr)rtws r _term_widthr)s! Q B  b c eZdZdZdZedZedZddddZd d d d d ddddZ d d d d d ddddZ dddddddZ ddddddd d!dZ d"d#d$d%d&d'd(d)dZ d*Zd7d,Zd7d-Zd.Zd/Zd0Zd8d1Zd2Zd3Zd4Zd5Zd6Zy+)9Termz>A class to provide some terminal "UI" helpers based on curses.TctSNrselfs rz Term.@s)9);rctSr)rr s rr"z Term.AsKMrsmulrevsgr0) underlinereversenormalrrblackbluegreencyanredmagentayellowwhite)r1r5r3r7r2r6r4r8zzzzz(Bboldblinkdimr(r'r)zzzzzzzzzzzzzzzzcj|j|_|j|_|j|_yr)_Term__ansi_forced_MODEMODE_Term__ansi_forced_FG_COLORFG_COLOR_Term__ansi_forced_BG_COLORBG_COLORr s r __forced_initzTerm.__forced_initzs)++ 33 33 rNc fd|_d|_|dk(r|jyddddddd|_ddddddddd|_ddddddddd|_|dk(rd |_y|d k(sJ|st j}|jsd |_y tj|j tj|_tjd |_|jD]?}|}||j vr|j |}|j#||j|<A|j#d j%d}|rW|j&j)D]:\}}tj*||j-xsd|j|<<|j#dj%d}|rY|j.j)D]<\}}tj*||j-xsd}||j|<>|j#dj%d} | rW|j&j)D]:\}}tj*| |j-xsd|j |<<|j#dj%d} | rZ|j.j)D]<\}}tj*| |j-xsd} | |j |<>yy#t$r d |_YywxYw)a Reinitializes the :class:`Term`. :param term_stream: the terminal stream that the :class:`Term` should be initialized to use. If *term_stream* is not given, :attr:`sys.stdout` is used. :param color: when to colorize output. Valid values are 'always', 'auto', and 'never'. 'always' will use ANSI codes to always colorize output, 'auto' will decide whether do colorize depending on the terminal, and 'never' will never colorize. TalwaysNr9r:r0neverFautorlinessetfzutf-8setafsetbsetab)_Term__enabledrK_Term__forced_initr@rBrDsysstdoutisattycurses setuptermfileno Exceptiontigetstr _ctigetstrtigetnum_Term__cap_names _tigetstrencode _Term__colorsitemstparmdecode_Term__ansi_colors) r! term_streamcolorcap_namemodeset_fgval set_fg_ansifg_colorset_bg set_bg_ansibg_colors rreinitz Term.reinits H            G "DN **K!!#"DN      2 2 4 5!//__W-  HD4+++++H5"nnX6DIIdO "'..w7  $ 3 3 5 '-||FC'@'G'G'I'OR e$!6nnW-44W=  $ 2 2 8 8 : !<< S9@@BHb'/ e$!;'..w7  $ 3 3 5 '-||FC'@'G'G'I'OR e$!6nnW-44W=  $ 2 2 8 8 : !<< S9@@BHb'/ e$!; ; "DN  s$LL0/L0c(|j||yr)ro)r!rdres r__init__z Term.__init__s K'rc|j|xsd}tjj|r|j }t j dd|S)Nr9z \$<\d+>[/*]?)rZdnfpycomp is_py3bytesrbresub)r!rfcaps rr]zTerm._tigetstrsGooh'-2 :: ! !# &**,Cvvor3//rcX|j|t|z|jdzS)zColorize string with colorr))r@str)r!ress rrez Term.colors( % 3q6)DIIh,??@rc&|jd|S)zMake string bold.r;)re)r!r{s rr;z Term.boldszz&!$$rc|js|S|stj}fd}|D]7}||} |rtjnd} tj| ||| }9|S)aSearch the string *haystack* for all occurrences of any string in the list *needles*. Prefix each occurrence with *beg*, and postfix each occurrence with *end*, then return the modified string. For example:: >>> yt = Term() >>> yt.sub('spam and eggs', 'x', 'z', ['and']) 'spam xandz eggs' This is particularly useful for emphasizing certain words in output: for example, calling :func:`sub` with *beg* = MODE['bold'] and *end* = MODE['normal'] will return a string that when printed to the terminal will appear to be *haystack* with each occurrence of the strings in *needles* in bold face. Note, however, that the :func:`sub_mode`, :func:`sub_bold`, :func:`sub_fg`, and :func:`sub_bg` methods provide convenient ways to access this same emphasizing functionality. :param haystack: the string to be modified :param beg: the string to be prefixed onto matches :param end: the string to be postfixed onto matches :param needles: a list of strings to add the prefixes and postfixes to :param escape: a function that accepts a string and returns the same string with problematic characters escaped. By default, :func:`re.escape` is used. :param ignore_case: whether case should be ignored when searching for matches :return: *haystack* with *beg* prefixing, and *end* postfixing, occurrences of the strings in *needles* c0|jzzSr)group)matchbegends rr"zTerm.sub..ssU[[]2S8rr)flags)rPrvescapeIrw) r!haystackrrneedlesr ignore_caserenderneedlepatrs `` rrwzTerm.subs^@~~OYYF8F.C'BDDQEvvc685AHrc H|j|||jd|fi|S)aOSearch the string *haystack* for all occurrences of any string in the list *needles*. Prefix each occurrence with *beg*, and postfix each occurrence with self.MODE['normal'], then return the modified string. If *beg* is an ANSI escape code, such as given by self.MODE['bold'], this method will return *haystack* with the formatting given by the code only applied to the strings in *needles*. :param haystack: the string to be modified :param beg: the string to be prefixed onto matches :param end: the string to be postfixed onto matches :param needles: a list of strings to add the prefixes and postfixes to :return: *haystack* with *beg* prefixing, and self.MODE['normal'] postfixing, occurrences of the strings in *needles* r))rwr@)r!rrrkwdss rsub_normz Term.sub_norm&s)"txx#tyy':GLtLLrc F|j||j||fi|S)aTSearch the string *haystack* for all occurrences of any string in the list *needles*. Prefix each occurrence with self.MODE[*mode*], and postfix each occurrence with self.MODE['normal'], then return the modified string. This will return a string that when printed to the terminal will appear to be *haystack* with each occurrence of the strings in *needles* in the given *mode*. :param haystack: the string to be modified :param mode: the mode to set the matches to be in. Valid values are given by self.MODE.keys(). :param needles: a list of strings to add the prefixes and postfixes to :return: *haystack* with self.MODE[*mode*] prefixing, and self.MODE['normal'] postfixing, occurrences of the strings in *needles* )rr@)r!rrgrrs rsub_modez Term.sub_mode9s&$t}}XtyyH4HHrc ,|j|d|fi|S)aSearch the string *haystack* for all occurrences of any string in the list *needles*. Prefix each occurrence with self.MODE['bold'], and postfix each occurrence with self.MODE['normal'], then return the modified string. This will return a string that when printed to the terminal will appear to be *haystack* with each occurrence of the strings in *needles* in bold face. :param haystack: the string to be modified :param needles: a list of strings to add the prefixes and postfixes to :return: *haystack* with self.MODE['bold'] prefixing, and self.MODE['normal'] postfixing, occurrences of the strings in *needles* r;)r)r!rrrs rsub_boldz Term.sub_boldMs t}}Xvw?$??rc F|j||j||fi|S)acSearch the string *haystack* for all occurrences of any string in the list *needles*. Prefix each occurrence with self.FG_COLOR[*color*], and postfix each occurrence with self.MODE['normal'], then return the modified string. This will return a string that when printed to the terminal will appear to be *haystack* with each occurrence of the strings in *needles* in the given color. :param haystack: the string to be modified :param color: the color to set the matches to be in. Valid values are given by self.FG_COLOR.keys(). :param needles: a list of strings to add the prefixes and postfixes to :return: *haystack* with self.FG_COLOR[*color*] prefixing, and self.MODE['normal'] postfixing, occurrences of the strings in *needles* )rrBr!rrerrs rsub_fgz Term.sub_fg_'$t}}Xt}}U';WMMMrc F|j||j||fi|S)aSearch the string *haystack* for all occurrences of any string in the list *needles*. Prefix each occurrence with self.BG_COLOR[*color*], and postfix each occurrence with self.MODE['normal'], then return the modified string. This will return a string that when printed to the terminal will appear to be *haystack* with each occurrence of the strings in *needles* highlighted in the given background color. :param haystack: the string to be modified :param color: the background color to set the matches to be in. Valid values are given by self.BG_COLOR.keys(). :param needles: a list of strings to add the prefixes and postfixes to :return: *haystack* with self.BG_COLOR[*color*] prefixing, and self.MODE['normal'] postfixing, occurrences of the strings in *needles* )rrDrs rsub_bgz Term.sub_bgsrr)NrJ)NF)__name__ __module__ __qualname____doc__rPproperty real_columnscolumnsr\r_rcr?rArCrQrorqr]rer;rwrrrrrrrrr4sHI;rs<&''  QN6QNr