ó ¾[/\c@@s¦ddlmZddlmZddlZddlZddlZddlZddlZddl Z ddl Z dd„Z dd„Z de fd„ƒYZdS( i(tabsolute_import(tunicode_literalsNicC@sUy<d}tj|tj|ƒ}tjd|ƒd}|SWntk rPdSXdS(u Get the real terminal width uabcdefghthhhhiN(tfcntltioctlttermiost TIOCGWINSZtstructtunpacktIOErrortNone(tfdtbuftret((s0/usr/lib/python2.7/site-packages/dnf/cli/term.pyt_real_term_widths cC@s1tddƒ}|sdS|dkr)dS|SdS(u@ Compute terminal width falling to default 80 in case of troubleR iiPiN(R(R ttw((s0/usr/lib/python2.7/site-packages/dnf/cli/term.pyt _term_width)s  tTermcB@sóeZdZeZed„ƒZed„ƒZidd6dd6dd6Zid d 6d d 6d d6dd6dd6dd6dd6dd6Z id d 6d d6d d6dd6dd 6dd6dd6dd6Z idd6dd6dd6dd6d d6d!d6Z id"d 6d#d6d$d6d%d6d&d 6d'd6d(d6d)d6Z id*d 6d+d6d,d6d-d6d.d 6d/d6d0d6d1d6Z d2„Zd?d3d4„Zd?d3d5„Zd6„Zd7„Zd8„Zd?ed9„Zd:„Zd;„Zd<„Zd=„Zd>„ZRS(@u>A class to provide some terminal "UI" helpers based on curses.cC@stƒS(N(R(tself((s0/usr/lib/python2.7/site-packages/dnf/cli/term.pyt@scC@stƒS(N(R(R((s0/usr/lib/python2.7/site-packages/dnf/cli/term.pyRAsusmulu underlineurevureverseusgr0unormaliublackiublueiugreeniucyaniurediumagentaiuyellowiuwhiteuubolduublinkuudimuuu(BuuuuuuuuuuuuuuuucC@s(|j|_|j|_|j|_dS(N(t_Term__ansi_forced_MODEtMODEt_Term__ansi_forced_FG_COLORtFG_COLORt_Term__ansi_forced_BG_COLORtBG_COLOR(R((s0/usr/lib/python2.7/site-packages/dnf/cli/term.pyt __forced_initzs  uautoc C@s„t|_d|_|dkr,|jƒdSidd6dd6dd6dd6dd 6dd 6|_idd 6dd 6dd 6dd6dd6dd6dd6dd6|_idd 6dd 6dd 6dd6dd6dd6dd6dd6|_|dkrút|_dS|dks t‚|st j }n|j ƒs7t|_dSyt j d|jƒƒWntk rnt|_dSXt j|_t jdƒ|_xL|jD]A}|}||jkrÂ|j|}n|j|ƒ|j|(RR3R4((s0/usr/lib/python2.7/site-packages/dnf/cli/term.pyt__init__åscC@sI|j|ƒpd}tjj|ƒr6|jƒ}ntjdd|ƒS(Nuu \$<\d+>[/*]?(R)tdnftpycompt is_py3bytesR1tretsub(RR5tcap((s0/usr/lib/python2.7/site-packages/dnf/cli/term.pyR,èscC@s |j|t|ƒ|jdS(uColorize string with colorunormal(Rtstr(RR4ts((s0/usr/lib/python2.7/site-packages/dnf/cli/term.pyR4ñscC@s|jd|ƒS(uMake string bold.ubold(R4(RRG((s0/usr/lib/python2.7/site-packages/dnf/cli/term.pytboldõsc @s…|js |S|stj}n‡‡fd†}xM|D]E}||ƒ} |rhtj| tjƒ} ntj| ||ƒ}q8W|S(uSearch 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* c@sˆ|jƒˆS(N(tgroup(tmatch(tbegtend(s0/usr/lib/python2.7/site-packages/dnf/cli/term.pyRs(RRCtescapettemplatetIRD( RthaystackRKRLtneedlesRMt ignore_casetrendertneedletpat((RKRLs0/usr/lib/python2.7/site-packages/dnf/cli/term.pyRDùs    cK@s |j|||jd||S(uOSearch 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* unormal(RDR(RRPRKRQtkwds((s0/usr/lib/python2.7/site-packages/dnf/cli/term.pytsub_norm&scK@s|j||j|||S(uTSearch 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* (RWR(RRPR6RQRV((s0/usr/lib/python2.7/site-packages/dnf/cli/term.pytsub_mode9scK@s|j|d||S(uÚSearch 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* ubold(RX(RRPRQRV((s0/usr/lib/python2.7/site-packages/dnf/cli/term.pytsub_boldMscK@s|j||j|||S(ucSearch 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* (RWR(RRPR4RQRV((s0/usr/lib/python2.7/site-packages/dnf/cli/term.pytsub_fg_scK@s|j||j|||S(u…Search 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* (RWR(RRPR4RQRV((s0/usr/lib/python2.7/site-packages/dnf/cli/term.pytsub_bgssN(t__name__t __module__t__doc__RRtpropertyt real_columnstcolumnsR+R.R2RRRRR R>R?R,R4RHRRDRWRXRYRZR[(((s0/usr/lib/python2.7/site-packages/dnf/cli/term.pyR4s~        f  -    (t __future__RRR$t dnf.pycompR@RRCRR!RRRtobjectR(((s0/usr/lib/python2.7/site-packages/dnf/cli/term.pyts