Mini Shell

Direktori : /usr/lib/python3.6/site-packages/simpleline/render/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/simpleline/render/__pycache__/adv_widgets.cpython-36.pyc

3

<�Zcm�@s�ddlZddlmZddlmZddlmZddlmZm	Z	ddl
mZddlm
Z
mZmZdd	d
ddd
gZGdd�de�ZGdd�de�ZGdd
�d
e�ZGdd�de�ZGdd	�d	e�ZGdd
�d
e�ZdS)�N)�widgets)�WindowContainer)�Prompt)�UIScreen�
InputState)�PasswordInputHandler)�_�N_�C_�ErrorDialog�GetInputScreen�GetPasswordInputScreen�
HelpScreen�PasswordDialog�YesNoDialogcs@eZdZdZ�fdd�Zd�fdd�	Zddd�Zd	d
�Z�ZS)
rz+Dialog screen for reporting errors to user.cst�j�td�|_||_dS)z\
        :param message: the message to show to the user
        :type message: str
        �ErrorN)�super�__init__r	�title�_message)�self�message)�	__class__��!/usr/lib/python3.6/adv_widgets.pyr#s

zErrorDialog.__init__Ncs.t�j|�tj|j�}|jjtj|��dS)N)r�refreshr�
TextWidgetr�window�add_with_separator�CenterWidget)r�args�text)rrrr,szErrorDialog.refreshcCsttd�tj�S)NzPress %s to exit)rr�ENTER)rr rrr�prompt1szErrorDialog.promptcCstjd�dS)zUThis dialog is closed by any input.

        And causes the program to quit.
        �N)�sys�exit)rr �keyrrr�input4szErrorDialog.input)N)N)	�__name__�
__module__�__qualname__�__doc__rrr#r(�
__classcell__rr)rrr s
	
csNeZdZdZd
�fdd�	Zd�fdd�	Zddd�Zed	d
��Zdd�Z	�Z
S)rz!Dialog screen for password input.Ncs,t�j�td�|_|ptd�|_d|_dS)zX
        :param message: password prompt question
        :type message: string
        ZPasswordzEnter your passphraseN)rrr	rrr�	_password)rr)rrrr?s

zPasswordDialog.__init__cs.t�j|�tj|j�}|jjtj|��dS)N)rrrrrrrr)rr r!)rrrrIszPasswordDialog.refreshcCsRt|d�}|jr|j|j�|jtd��|j�|j�s>dS|j|_|j	�dS)N)�sourcezPassphrase: )
rZ
password_funcZ
set_pass_funcZ	get_inputrZ
wait_on_inputZinput_successful�valuer.�close)rr Zhandlerrrrr#Ns
zPasswordDialog.promptcCs|jS)z?The response can be None (no response) or the password entered.)r.)rrrr�answerbszPasswordDialog.answercCs|r||_tjStjSdS)N)r.r�PROCESSED_AND_CLOSE�	DISCARDED)rr r'rrrr(gszPasswordDialog.input)N)N)N)r)r*r+r,rrr#�propertyr2r(r-rr)rrr<s

csLeZdZdZ�fdd�Zd
�fdd�	Zddd�Zd	d
�Zedd��Z	�Z
S)rz%Dialog screen for Yes - No questions.cs$t�j�td�|_||_d|_dS)z`
        :param message: the message to show to the user
        :type message: unicode
        ZQuestionN)rrr	rr�	_response)rr)rrrrrs

zYesNoDialog.__init__Ncs.t�j|�tj|j�}|jjtj|��dS)N)rrrrrrrr)rr r!)rrrr|szYesNoDialog.refreshcCs"ttd�tdd�tdd�d��S)Nz$Please respond '%(yes)s' or '%(no)s'zTUI|Spoke Navigation�yes�no)r7r8)rrr
)rr rrrr#�szYesNoDialog.promptcCs>|tdd�krd|_tjS|tdd�kr4d|_tjStjSdS)NzTUI|Spoke Navigationr7Tr8F)r
r6rr3r4)rr r'rrrr(�szYesNoDialog.inputcCs|jS)zAThe response can be True (yes), False (no) or None (no response).)r6)rrrrr2�szYesNoDialog.answer)N)N)r)r*r+r,rrr#r(r5r2r-rr)rrros

cs@eZdZdZ�fdd�Zd�fdd�	Zdd�Zdd	d
�Z�ZS)
rz!Screen to display a help message.cst�j�td�|_||_dS)zO
        :param help_path: help file name
        :type help_path: str
        ZHelpN)rrr	r�	help_path)rr9)rrrr�s

zHelpScreen.__init__Nc
sPt�j|�td�}|jr:t|jd��}|j�}WdQRX|jjtj	|��dS)z Show the help. zThe help is not available.�rN)
rrrr9�open�readrrrr)rr Zhelp_message�f)rrrr�szHelpScreen.refreshcCstjS)z Handle user input. )rr3)rr r'rrrr(�szHelpScreen.inputcCsttd�tj�S)NzPress %s to return)rrr")rr rrrr#�szHelpScreen.prompt)N)N)	r)r*r+r,rrr(r#r-rr)rrr�s
	csfeZdZdZ�fdd�Zedd��Zddd�Zd	d
�Zd�fdd�	Z	dd
d�Z
dd�Zdd�Z�Z
S)rzScreen for getting user input.cs t�j�||_d|_g|_dS)z^
        :param message: Prompt printed before user input.
        :type message: str
        N)rrr�_value�_conditions)rr)rrrr�s
zGetInputScreen.__init__cCs|jS)zUser input.)r>)rrrrr0�szGetInputScreen.valueNcCs|jj||f�dS)a6Add acceptance condition to the conditions list.

        :param acceptance_function: Functions that accepts or rejects a user input.
        :type acceptance_function: `function(input, args) -> bool`  - function which takes
                                   user input (string) and arguments (`args`) and return True when input is accepted or
                                   False if rejected so we will ask for a new input.

        :param args: Second argument for `acceptance_function` the first one will be user input.
        :type args: Anything.
        N)r?�append)rZacceptance_functionr rrr�add_acceptance_condition�sz'GetInputScreen.add_acceptance_conditioncCs|jj�dS)z(Clear list of the acceptance conditions.N)r?�clear)rrrr�clear_acceptance_conditions�sz*GetInputScreen.clear_acceptance_conditionscst�j|�t�|_dS)N)rrrZ_window)rr )rrrr�szGetInputScreen.refreshcCst|jd�S)N)r)rr)rr rrrr#�szGetInputScreen.promptcCs|j|�stjS||_tjS)N)�_test_inputrr4r>r3)rr r'rrrr(�s
zGetInputScreen.inputcCs&x |jD]\}}|||�sdSqWdS)NFT)r?)rr'r=r rrrrD�s
zGetInputScreen._test_input)N)N)N)r)r*r+r,rr5r0rArCrr#r(rDr-rr)rrr�s



cs eZdZdZ�fdd�Z�ZS)r
z'Screen for getting user password input.cst�j|�d|_dS)NT)rrZhide_user_input)rr)rrrr�szGetPasswordInputScreen.__init__)r)r*r+r,rr-rr)rrr
�s)r%Zsimpleline.renderrZsimpleline.render.containersrZsimpleline.render.promptrZsimpleline.render.screenrrZsimpleline.input.input_handlerrZsimpleline.utils.i18nrr	r
�__all__rrrrrr
rrrr�<module>s3.: