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/messaging/answerstore.pyc
�
g��fc@s�ddlZddlZddlmZyddlmZWn!ek
r_ddlmZnXddlm	Z	ddl
mZd�Zde
fd	��YZdS(
i����N(tconfigparser(tSafeConfigParser(tConfigParser(tCommandError(tcreate_audit_entrycCs�t|�}g|jd�D]}|j�r|^q}djd|rXdj|�ndd|dddjg|d	D]}td|�^qy��}|S(
sWReturns a commented-out string. If any newlines are present it properly deals with thems
s# {key:<20}{line1}
{linesN}tkeys{}:ttline1itlinesNi(tstrtsplittstriptformattjoint_comment_out(Rttexttstsplit_by_newlinetlinetres((s?/usr/lib/python2.7/site-packages/leapp/messaging/answerstore.pyRs.$
	)tAnswerStorecBsweZdZdd�Zd�Zed��Zed�Z	d�Z
d�Zdd�Zd�Z
d	�Zd
�ZRS(sR
    AnswerStore handles storing and loading answer files for user questions.
    cCs+|ptj�|_|jj�|_dS(s�
        Initialize the answer store.
        :param manager: Passes through a given instance of multiprocessing.Manager() to use, by default it creates
                        an own instance.
        N(tmultiprocessingtManagert_managertdictt_storage(tselftmanager((s?/usr/lib/python2.7/site-packages/leapp/messaging/answerstore.pyt__init__scCs0|jj|i�}|||<||j|<dS(N(Rtget(RtscopeRtvaluetdialog_scope((s?/usr/lib/python2.7/site-packages/leapp/messaging/answerstore.pytanswer's
cCsbtdt�}y|j|�|SWn7tjk
r]}tdjd|d|j���nXdS(s�
        Loads an ini config file from the given location.

        :param inifile: Path to the answer file to load.
        :return: configparser.ConfigParser object
        :raises CommandError if any of the values are not in key=value format
        tallow_no_valuesHFailed to load answer file {inifile} with the following errors: {errors}tinifileterrorsN(RtFalsetreadRtParsingErrorRRtmessage(tclsR#tconftexc((s?/usr/lib/python2.7/site-packages/leapp/messaging/answerstore.pyt	_load_ini/s	
c
Cs�tj|�}g}x�|jj�D]�\}}x�|j�D]�\}}||j�krr|rr|j|�ny|j||t|��Wq>tj	k
r�|j
djd|d|d|��q>Xq>Wq%Wt|d��}	|j
|	�WdQX|S(s�
        Update answerfile with all answers from answerstore that have correspondent sections in the file.

        Returns a list of sections that were not found in original answerfile and thus were not updated.
        s{sec}.{opt}={val}tsectopttvaltwN(RR,Rtitemstsectionstadd_sectiontsetR	RtNoSectionErrortappendRtopentwrite(
Rtanswer_filet
allow_missingR*tnot_updatedtsectiont
answerdictR.R/tafile((s?/usr/lib/python2.7/site-packages/leapp/messaging/answerstore.pytupdateBs1cCsUtj|�}x?|j�D]1}|jj|jd|dt��|j|<qWdS(s
        Loads an answer file from the given location and updates the loaded data with it.

        :param answer_file: Path to the answer file to load.
        :return: None
        :raises CommandError if any of the values are not in key=value format
        R<trawN(RR,R2RRR1tTrueR(RR9R*R<((s?/usr/lib/python2.7/site-packages/leapp/messaging/answerstore.pytloadWscCs\tj|�}x9|j�D]+}t|jd|dt��|j|<qW|j|�dS(s�
        Loads an answer file from the given location and updates the loaded data with it and translates the data to
        the correct value types based on the dialogs in the given workflow.

        :param answer_file: Path to the answer file to load.
        :param workflow:
        :return: None
        :raises CommandError if any of the values are not in key=value format
        R<R@N(RR,R2RR1RARttranslate_for_workflow(RR9tworkflowR*R<((s?/usr/lib/python2.7/site-packages/leapp/messaging/answerstore.pytload_and_translate_for_workflowcs
)cCsA|jj||�j�}tdi|d6|d6|d6�|S(s
        Dict compatible interface to get a sub dictionary by dialog scope.

        :param scope: Scope of the data to retrieve.
        :param fallback: Fallback value to return if not found.
        :return: A shallow copy of data stored in _storage by scope key
        s
dialog-answerRtfallbackR!(RRtcopyR(RRRFR!((s?/usr/lib/python2.7/site-packages/leapp/messaging/answerstore.pyRrs
"cCs%x|jD]}|j|�q
WdS(s�
        Translates the data for all dialogs in the current workflow.

        :param workflow: Instance of a workflow to translate all dialogs from.
        :type workflow: :py:class:`leapp.workflows.Workflow`
        :return: None
        N(tdialogst	translate(RRDtdialog((s?/usr/lib/python2.7/site-packages/leapp/messaging/answerstore.pyRC�scCs||jj|j�}|rxx=|jD]2}|j|kr%t||jtj�r%|jt	kr�||jj
�dk||j<n�|jtkr�t||j�||j<n�|jtkr�||jj
d�}tt|�j|j��||j<nAt|d�r?||j}||jkr/|nd||j<n|j|j�|_q%q%W|jji||j6�ndS(s&
        Translates configuration values from their string form to the corresponding value format based on the given
        dialog.

        :param dialog: A dialog instance to translate the data for.
        :type dialog: :py:class:`leapp.dialogs.dialog.Dialog`
        :return: None
        ttruet;tchoicesN(RRRt
componentsRt
isinstancetsixtstring_typest
value_typetbooltlowertintttupleR
R4tintersectionRMthasattrtNoneRR?(RRJtentryt	componenttelementsR((s?/usr/lib/python2.7/site-packages/leapp/messaging/answerstore.pyRI�s 	(#(
%c
Cs!t|d��}x|D]�}|js.qn|jdj|j�td|j�td|j�g�x�|jD]�}|jj	|ji�j	|j
�}|j}d}d}	t|d�r'|djdj
|j��7}|jtkr'd	j
|j�}|rd	j
|�n|}d
}	q'n|dk	rU|	djd|j
d
|�7}	n/|	d7}	|	djd|j
d
|p}d�7}	|jdjdj|j|j
�jdd��td|j�td|j�td|j�td|jj�td|�||	dg	�qrWqWWdQXdS(s�
        Generates an answer file for the given dialogs and stores it to `answer_file_path`.
        :param dialogs:
        :param answer_file_path:
        :return:
        R0s[{}]
tTitletReasonRRMs# Available choices: {}
t/RLs+#
# Values are separated by semi-colon ";"
s{key} = {value}
RRsE# Unanswered question. Uncomment the following line with your answer
s# {key} = {value}
s# {}
s {}.{} iMt=tLabeltDescriptiontTypetDefaults
N(R7RNt
writelinesRRRttitletreasonRRRtdefaultRXR
RMRRRVRYtcentertlabeltdescriptiont__name__(
RRHtanswer_file_pathtfRJR[R!RhRMtanswer_entry((s?/usr/lib/python2.7/site-packages/leapp/messaging/answerstore.pytgenerate�sB
	$	"
%*N(Rlt
__module__t__doc__RYRR!tclassmethodR,R%R?RBRERRCRIRp(((s?/usr/lib/python2.7/site-packages/leapp/messaging/answerstore.pyRs						(RRPt	six.movesRtsix.moves.configparserRRtImportErrortleapp.exceptionsRtleapp.utils.auditRRtobjectR(((s?/usr/lib/python2.7/site-packages/leapp/messaging/answerstore.pyt<module>s