Mini Shell

Direktori : /lib/python3.6/site-packages/meh/ui/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/meh/ui/__pycache__/text.cpython-36.pyc

3

��\��@sddlmZddlmZmZmZmZddlmZm	Z	m
Z
mZddlZddl
ZddlmZmZddlZddlZejjdkr~eZneZddlZdd�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�ZGdd�dee	�ZGdd�dee
�ZGdd�dee�ZGdd�de�Z dS)�)�print_function)�MAIN_RESPONSE_DEBUG�MAIN_RESPONSE_SAVE�MAIN_RESPONSE_SHELL�MAIN_RESPONSE_QUIT)�AbstractIntf�AbstractSaveExceptionWindow�AbstractMainExceptionWindow�AbstractMessageWindowN)�LIBREPORT_WAIT�LIBREPORT_RUN_CLI�cCs |dkrtjddd�j|�SdS)N�z
python-mehT)Zfallback)�gettextZtranslation)�x�r�/usr/lib/python3.6/text.py�<lambda>$src@s0eZdZdZeefdd�Zd
dd�Zdd�Zd	S)�	IOHandlerz�
    Class that provides methods for input and output. Its instance is expected
    to be passed to objects performing some I/O operations.

    cCs||_||_dS)a\
        Constructor for the IOhandler class. Arguments can be used to override
        default I/O functions with the custom ones.

        :param in_func: input function similar to standard raw_input
        :type in_func: str -> str
        :param out_func: output function similar to standard print
        :type out_func: str -> None

        N)�in_func�out_func)�selfrrrrr�__init__.szIOHandler.__init__rcCs|j|�dS)N)r)r�msgrrr�print=szIOHandler.printcCs
|j|�S)N)r)r�promptrrr�	raw_input@szIOHandler.raw_inputN)r)�__name__�
__module__�__qualname__�__doc__�raw_input_fnrrrrrrrr's
rc@s<eZdZdZdd�Zedd��Zdd�Zdd	�Zd
d�Z	dS)
�
TextWindowzFHelper class providing some common methods needed by all text windows.cOs.|jdt��|_||_td�|_td�|_dS)N�
io_handler�y�n)�getr�_io�_title�_�_yes_answer�
_no_answer)r�title�args�kwargsrrrrFs
zTextWindow.__init__cCstjjdd�dS)NZCOLUMNS�P�)�os�environr&)rrrr�
_usable_widthPszTextWindow._usable_widthcCs|jd}|jj|�dS)N�=)r3r'r)rZrulerrr�_print_ruleTs
zTextWindow._print_rulecCs,|jj�|j�|jj|j�|j�dS)N)r'rr5r()rrrr�print_headerXs
zTextWindow.print_headercCs|j�|j�dS)N)r5)rrrr�destroy^szTextWindow.destroyN)
rrrr r�propertyr3r5r6r7rrrrr"Cs
r"c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�TextIntfcOs4tj|f|�|�|jdd�|_|jdt��|_dS)N�screenr#)rrr&r:rr')rr-r.rrrrcszTextIntf.__init__cCs
||_dS)zg
        Set different IO handler.

        :type handler: an instance of the IOHandler class

        N)r')rZhandlerrrr�set_io_handlerhszTextIntf.set_io_handlercOsdS)z+Should be provided by the inheriting class.Fr)rr-r.rrr�
enableNetworkqszTextIntf.enableNetworkcOs0|j|d<t||f|�|�}|j�|j�dS)Nr#)r'�
ExitWindow�runr7)rr,�messager-r.�winrrr�
exitWindowvs
zTextIntf.exitWindowcOs |j|d<t||f|�|�}|S)Nr#)r'�MainExceptionWindow)r�textZexnFiler-r.r@rrr�mainExceptionWindow|s
zTextIntf.mainExceptionWindowcOs0|j|d<t||f|�|�}|j�|j�dS)Nr#)r'�
MessageWindowr>r7)rr,r?r-r.r@rrr�
messageWindow�s
zTextIntf.messageWindowcOs.|j|d<t|f|�|�}|j�|j�dS)Nr#)r'�SaveExceptionWindowr>r7)r�	signaturer-r.r@rrr�saveExceptionWindow�s
zTextIntf.saveExceptionWindowN)
rrrrr;r<rArDrFrIrrrrr9bs	r9c@seZdZdd�Zdd�ZdS)rGcOs6tj||f|�|�tj|td�f|�|�||_dS)NzSave exception)rrr"r)rH)rrHr-r.rrrr�s

zSaveExceptionWindow.__init__cOstj|jttB�dS)N)�reportZreport_problem_in_memoryrHrr)rr-r.rrrr>�szSaveExceptionWindow.runN)rrrrr>rrrrrG�srGc@seZdZddd�Zdd�ZdS)rBNcOs�tj|||f|�|�tj|td�f|�|�||_td�tftd�tftd�tfg|_|j	dt
jj�}|r�|�r�|jj
dtd�tf�dS)NzAn unknown error has occurredz
Report Bugz	Run shellZQuit�
allowDebugr0ZDebug)r	rr"r)�_short_tracebackrrr�_menu_itemsr&�sys�stdout�isatty�insertr)rZshortTracebackZ
longTracebackr-r.rKrrrr�s




zMainExceptionWindow.__init__cOs�|j�|jj|j�|jjtd��x2t|j�D]$\}}|jjd|d|df�q2Wd}t|j�}|jj�xRd|ko�|kns�|jjtd��}yt	|�}Wqtt
k
r�d}YqtXqtW|j|ddS)NzWhat do you want to do now?z%d) %sr0rz$Please make your choice from above: ���rR)r6r'rrLr)�	enumeraterM�lenr�int�
ValueError)rr-r.�idx�item�retZnum_menu_itemsrrrr>�s 

zMainExceptionWindow.run)NN)rrrrr>rrrrrB�s
rBc@seZdZdd�Zdd�ZdS)rEcOs4tj|||f|�|�tj||f|�|�||_dS)N)r
rr"�_text)rr,rCr-r.rrrr�szMessageWindow.__init__cOs4|j�|jj|j�|jj�|jjtd��dS)NzHit ENTER to continue)r6r'rrZrr))rr-r.rrrr>�s
zMessageWindow.runN)rrrrr>rrrrrE�srEc@seZdZdd�Zdd�ZdS)r=cOstj|||f|�|�dS)N)rEr)rr,rCr-r.rrrr�szExitWindow.__init__cOs�|j�|jj|j�|jj�|jjd�j�jd�}|jjt	d�|j
|d��}|jd�j�jd�}|pn|j}||j
|jfkr�||j
kS|j||�dS)Nzutf-8z/Are you sure you want to exit? [%(yes)s/%(no)s])�yes�no)
r6r'rrZr+�decode�upper�encoderr)r*�lowerr>)rr-r.Zno_answer_upperZanswerZlower_answerrrrr>�s


zExitWindow.runN)rrrrr>rrrrr=�sr=)!Z
__future__rZmehrrrrZmeh.uirrr	r
rJZreport.io.TextIOrrr1rN�version_info�major�inputr!rrr)�objectrr"r9rGrBrEr=rrrr�<module>s&+
#