MOON
Server: Apache
System: Linux server2.shieldcogroup.com 3.10.0-1160.119.1.el7.tuxcare.els12.x86_64 #1 SMP Fri Nov 8 05:49:38 UTC 2024 x86_64
User: jacom (1029)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python2.7/site-packages/leapp/dialogs/renderer.pyc
�
g��fc@s~ddlmZddlmZddlZejr>eZnddlmZdefd��YZ	de	fd��YZ
dS(	i����(tprint_function(tgetpassN(tinputtDialogRendererBasecBsVeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	s- Base class for all renderer implementations cCsdS(N((tself((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyt__init__scCs
t��dS(s�
        Renders the given dialog

        :param dialog: The dialog to render
        :type dialog: leapp.dialogs.dialog.Dialog
        :return: None
        N(tNotImplementedError(Rtdialog((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pytrenderscCs
t��dS(s$
        Renders the password component

        :param component: The password component to render
        :type component: leapp.dialogs.components.PasswordComponent
        :param dialog: The dialog to render
        :type dialog: leapp.dialogs.dialog.Dialog
        :return: None
        N(R(Rt	componentR((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pytrender_password_components
cCs
t��dS(s
        Renders the text component

        :param component: The text component to render
        :type component: leapp.dialogs.components.TextComponent
        :param dialog: The dialog to render
        :type dialog: leapp.dialogs.dialog.Dialog
        :return: None
        N(R(RR	R((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pytrender_text_component(s
cCs
t��dS(s!
        Renders the choices component

        :param component: The choices component to render
        :type component: leapp.dialogs.components.ChoicesComponent
        :param dialog: The dialog to render
        :type dialog: leapp.dialogs.dialog.Dialog
        :return: None
        N(R(RR	R((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pytrender_choice_component4s
cCs
t��dS(s:
        Renders the multiple choices component

        :param component: The multiple choices component to render
        :type component: leapp.dialogs.components.MultipleChoiceComponent
        :param dialog: The dialog to render
        :type dialog: leapp.dialogs.dialog.Dialog
        :return: None
        N(R(RR	R((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyt render_multiple_choice_component@s
cCs
t��dS(sA
        Renders the boolean component for displaying Yes/No questions

        :param component: The boolean component to render
        :type component: leapp.dialogs.components.BooleanComponent
        :param dialog: The dialog to render
        :type dialog: leapp.dialogs.dialog.Dialog
        :return: None
        N(R(RR	R((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pytrender_bool_componentLs
cCs
t��dS(s
        Renders the number component

        :param component: The number component to render
        :type component: leapp.dialogs.components.NumberComponent
        :param dialog: The dialog to render
        :type dialog: leapp.dialogs.dialog.Dialog
        :return: None
        N(R(RR	R((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pytrender_number_componentXs
(t__name__t
__module__t__doc__RRR
RRR
RR(((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyRs		
					tCommandlineRenderercBs�eZdZd�Zd�Zed��Zed��Zdd�Z	edd��Z
d�Zd�Zddd	�Z
d
�Zd�Zd�Zd
�Zed��Zed��ZRS(sX
    CommandlineRenderer implements the handling for commandline user interactions.
    cCs
t|_dS(N(R(R((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyRiscCsr|jr|j|j�n|jr8|j|j�nx3|jD](}|jdkrB|j||�qBqBWdS(s�
        Renders the given dialog

        :param dialog: The dialog to render
        :type dialog: leapp.dialogs.dialog.Dialog
        :return: None
        N(ttitlet
_render_titletreasont_render_reasont
componentstvaluetNonetdispatch(RRR	((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyRls		cCs(tdj|t|�dd��dS(sf
        Renders a title.

        :param value: Title value to print.
        :return:  None
        s
{}:
{}
it=N(tprinttformattlen(R((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyR}scCst|d�dS(sa
        Prints a reason string.

        :param value: String to print
        :return:
        s
N(R(R((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyR�scCsC|j||�j�}t|�|r?t|t|��ndS(s�
        Actual rendering of the given label. (Printing it to the output)

        :param value: Label to print.
        :param min_label_width: Minimum label length.
        :param underline: If set, it will print the given value in a second line as many times as there are characters
                        in the formatted label. That means if one would pass '-' it will underline the given value.
        :return: None
        N(t
_format_labeltstripRR(RRtmin_label_widtht	underlinetline((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyt
_render_label�s

cCsN|dkrd}ndj|�}dt|d�djd||d�S(	s�
        Implementation of component label formatting.

        :param value: String label to format
        :param min_label_width: Minimum width for the label. used to calculate the padding required.
        :param default: In case a default value needs to be displayed, this should be set and it will be printed after
                        the label text in square brackets.
        :return: The formatted label string.
        ts [{}]s	{value: >iss}Rs: N(RRtstr(RR"tdefault((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyR �s	c	Cs;|j||jd|j|jp$dd|j���dS(s$
        Renders the password component

        :param component: The password component to render
        :type component: leapp.dialogs.components.PasswordComponent
        :param dialog: The dialog to render
        :type dialog: leapp.dialogs.dialog.Dialog
        :return: None
        tprompts
Password: R"N(tanswerRR tlabelR"(RR	R((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyR
�s
'cCs|j||�S(s
        Renders the text component

        :param component: The text component to render
        :type component: leapp.dialogs.components.TextComponent
        :param dialog: The dialog to render
        :type dialog: leapp.dialogs.dialog.Dialog
        :return: None
        (t_render_text_component(RR	R((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyR�s
cCs�|dkr|j}nx�tr�t|j|jd|d|j��}|rj|jdk	rj|j}n4|r�|r�||||�rPqqn|s�qn|j||�PqWdS(s�
        Performs the actual rendering of the text component.

        :param component: The text component to render
        :type component: leapp.dialogs.components.TextComponent
        :param dialog: The dialog to render
        :type dialog: leapp.dialogs.dialog.Dialog
        :param result_hook: An optional hook to handle special result values (e.g. bool/integral cases)
        :param default_hint: An optional override of the default_hint to show.
        :return: None
        R(R"N(RR(tTrueRR R+R"R*(RR	Rtresult_hooktdefault_hinttresult((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyR,�s	$c
s��js
dSd}t�}�jrJ�jrJ�fd��jD�}nx�tr�|j�jd|jdd�xvt�j�D]e\}}d}�jr�dj	||kr�d	nd
�}nt
dj	d||d
|d|��q�Wd}�jdk	rU�jr4dj	t�fd��jD���}qUdj	�jj
�j��}n�jrgd}	ndj	d|�}	t|j|	t|	���}
�jr^|
s�|j�ttg|D]}�j|^q����Pnt|
�dkr�d|j
|
�kot�j�knr�|j
|
�}||krK|j|�q[|j|�q�qM|
r��jdk	r�|j��j�Pnt|
�dkrMd|j
|
�ko�t�j�knrM|j��j|j
|
��PqMqMWdS(s!
        Renders the choices component

        :param component: The choices component to render
        :type component: leapp.dialogs.components.ChoicesComponent
        :param dialog: The dialog to render
        :type dialog: leapp.dialogs.dialog.Dialog
        :return: None
        Nt$0123456789abcdefghijklmnopqrstuvwxyzcs"h|]}�jj|��qS((tchoicestindex(t.0tx(R	(s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pys	<setcomp>�s	R"R#t-R&s [{}] tXt s   {answer}. {checked}{label}R*R+tcheckeds [{}]c3s!|]}�jj|�VqdS(N(R2R3(R4R5(R	(s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pys	<genexpr>ss2Which entry to toggle (Empty response to continue)sChoice{default}R(ii����(R2tsettmultiR(R-R%R+R"t	enumerateRRRttupleR3RR RR*tsortedtremovetadd(RR	RtindicestselectedtidxtchoiceR9R(R+R0R5((R	s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyR�sJ
				$*	+!			6@@ cCs|j||�dS(s:
        Renders the multiple choices component

        :param component: The multiple choices component to render
        :type component: leapp.dialogs.components.MultipleChoiceComponent
        :param dialog: The dialog to render
        :type dialog: leapp.dialogs.dialog.Dialog
        :return: None
        N(R(RR	R((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyR
s
cCsmdj|j�}|jdk	rJ|jr:|jd}qJ|jd}n|j||d|jd|�dS(sA
        Renders the boolean component for displaying Yes/No questions

        :param component: The boolean component to render
        :type component: leapp.dialogs.components.BooleanComponent
        :param dialog: The dialog to render
        :type dialog: leapp.dialogs.dialog.Dialog
        :return: None
        s{}/{}iiR.R/N(RtvaluesR(RR,t_bool_result_hook(RR	RR/((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyR&s
	cCs|j||d|j�dS(s
        Renders the number component

        :param component: The number component to render
        :type component: leapp.dialogs.components.NumberComponent
        :param dialog: The dialog to render
        :type dialog: leapp.dialogs.dialog.Dialog
        :return: None
        R.N(R,t_int_result_hook(RR	R((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyR9s
cCs7y|j|t|��tSWntk
r2tSXdS(s
        Special hook to handle integral value results

        :param component: Component that is being currently handled
        :param dialog: Dialog the component belongs to
        :param result: Value of the result
        :return: True if the value was valid
        N(R*tintR-t
ValueErrortFalse(R	RR0((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyRGEs


cCs�|jdj�}|jdj�}||f}|f}|d|dkr{||d|df7}||df7}n|j�}||k}|r�|j|||k�n|S(s
        Special hook to handle boolean value results

        :param component: Component that is being currently handled
        :param dialog: Dialog the component belongs to
        :param result: Value of the result
        :return: True if the value was valid
        ii(REtlowerR*(R	RR0t
true_valuetfalse_valuetvalid_valuesttrue_valuestvalid((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyRFUs	N(RRRRRtstaticmethodRRRR%R R
RR,RR
RRRGRF(((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyRes"		

	
		4			(t
__future__RRtsixtPY2t	raw_inputRtbuiltinstobjectRR(((s:/usr/lib/python2.7/site-packages/leapp/dialogs/renderer.pyt<module>s		Y