ok

Mini Shell

Direktori : /lib/python3.6/site-packages/dnf/cli/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/dnf/cli/__pycache__/term.cpython-36.pyc

3

�ft`f9�@sxddlmZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddd�Zddd�ZGd	d
�d
e
�ZdS)
�)�absolute_import)�unicode_literalsN�cCsBy(d}tj|tj|�}tjd|�d}|Stk
r<dSXdS)z Get the real terminal width ZabcdefghshhhhrN)�fcntlZioctl�termiosZ
TIOCGWINSZ�struct�unpack�IOError)�fdZbuf�ret�r�/usr/lib/python3.6/term.py�_real_term_widthsrcCs&tdd�}|sdS|dkrdS|SdS)z@ Compute terminal width falling to default 80 in case of troubler)r
�P�N)r)r
Ztwrrr
�_term_width)s
rc	@seZdZdZdZedd��Zedd��Zdddd	�Zd
ddd
ddddd�Z	d
ddd
ddddd�Z
ddddddd�Zdddddd d!d"d�Zd#d$d%d&d'd(d)d*d�Z
d+d,�ZdFd/d0�ZdGd1d2�Zd3d4�Zd5d6�Zd7d8�ZdHd:d;�Zd<d=�Zd>d?�Zd@dA�ZdBdC�ZdDdE�Zd-S)I�Termz>A class to provide some terminal "UI" helpers based on curses.TcCst�S)N)r)�selfrrr
�<lambda>@sz
Term.<lambda>cCst�S)N)r)rrrr
rAsZsmulZrevZsgr0)�	underline�reverse�normalrr������)�black�blue�green�cyan�red�magenta�yellow�white)rr"r r$rr#r!r%zz�zzz(B)�bold�blink�dimrrrzzzzzzzzzzzzzzzzcCs|j|_|j|_|j|_dS)N)�_Term__ansi_forced_MODE�MODE�_Term__ansi_forced_FG_COLOR�FG_COLOR�_Term__ansi_forced_BG_COLOR�BG_COLOR)rrrr
Z
__forced_initzszTerm.__forced_initN�autocCsXd|_d|_|dkr |j�dSddddddd�|_ddddddddd�|_ddddddddd�|_|dkrvd	|_dS|d
ks�t�|s�tj}|j	�s�d	|_dSyt
j|j�d�Wnt
k
r�d	|_dSXt
j|_t
jd�|_x8|jD].}|}||jk�r|j|}|j|�|j|<q�W|jd
�jd�}|�rhx4|jj�D]&\}}t
j||�j��pZd|j|<�q>W|jd�jd�}|�r�x8|jj�D]*\}}t
j||�j��p�d}||j|<�q�W|jd�jd�}	|	�rx4|jj�D]&\}}t
j|	|�j��p�d|j|<�q�W|jd�jd�}
|
�rTx8|jj�D]*\}}t
j|
|�j��pBd}||j|<�q&WdS)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.
        T��alwaysNr&)r'r(r)rrr)rrr r!r"r#r$r%ZneverFr0)r
�linesZsetfzutf-8ZsetafZsetbZsetab)�_Term__enabledr3�_Term__forced_initr+r-r/�AssertionError�sys�stdout�isatty�cursesZ	setupterm�fileno�	ExceptionZtigetstr�
_ctigetstrZtigetnum�_Term__cap_names�	_tigetstr�encode�
_Term__colors�itemsZtparm�decode�_Term__ansi_colors)r�term_stream�color�cap_name�modeZset_fg�valZset_fg_ansiZfg_colorZset_bgZset_bg_ansiZbg_colorrrr
�reinits�



""zTerm.reinitcCs|j||�dS)N)rJ)rrErFrrr
�__init__�sz
Term.__init__cCs0|j|�pd}tjj|�r"|j�}tjdd|�S)Nr&z\$<\d+>[/*]?)r=�dnfZpycompZis_py3bytesrC�re�sub)rrGZcaprrr
r?�szTerm._tigetstrcCs|j|t|�|jdS)zColorize string with colorr)r+�str)rrF�srrr
rF�sz
Term.colorcCs|jd|�S)zMake string bold.r')rF)rrPrrr
r'�sz	Term.boldFc
s\|js
|S|stj}��fdd�}x4|D],}||�}	|rFtj|	tj�}	tj|	||�}q(W|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*
        cs�|j��S)N)�group)�match)�beg�endrr
rszTerm.sub.<locals>.<lambda>)r4rM�escape�template�IrN)
r�haystackrSrT�needlesrUZignore_caseZrenderZneedleZpatr)rSrTr
rN�s 
zTerm.subcKs|j|||jd|f|�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)rNr+)rrXrSrY�kwdsrrr
�sub_norm&sz
Term.sub_normcKs|j||j||f|�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*
        )r[r+)rrXrHrYrZrrr
�sub_mode9sz
Term.sub_modecKs|j|d|f|�S)a�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*
        r')r\)rrXrYrZrrr
�sub_boldMsz
Term.sub_boldcKs|j||j||f|�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*
        )r[r-)rrXrFrYrZrrr
�sub_fg_szTerm.sub_fgcKs|j||j||f|�S)a�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*
        )r[r/)rrXrFrYrZrrr
�sub_bgsszTerm.sub_bg)Nr0)Nr0)NF)�__name__�
__module__�__qualname__�__doc__r4�propertyZreal_columns�columnsr>rArDr*r,r.r5rJrKr?rFr'rNr[r\r]r^r_rrrr
r4sr	
f
	
-r)r)r)Z
__future__rrr:Z
dnf.pycomprLrrMrr7rrr�objectrrrrr
�<module>s



Zerion Mini Shell 1.0