
                             d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ dd	lmZ d
Zd Zd Z G d dej$                        Zy)z;Serves the survey and logs the response to clearcut tables.    )absolute_import)division)unicode_literals)concord_util)base)survey)log)
console_ioGeneralSurveyc                    | j                   }	 t        j                  |      }|t        j                  j
                  j                  j                  k(  r$t        j                  j
                  j                  S |t        j                  j
                  j                  j                  k(  r$t        j                  j
                  j                  S | j                  |      r|S | j                  })z,Prompts user for the answer to the question.)instructionr
   PromptResponser   SurveyControlOperationSKIP_QUESTIONvalueEXIT_SURVEYAcceptAnswerinstruction_on_rejection)question
prompt_msganswers      lib/surface/survey.py_GetAnswerToQuestionr       s    ##*&&z2F//==CCC]]++999	6==11==CC	C]]++777			v	&m44j 	    c                     t        j                  d      }|rt        j                  |        yt        j
                  j                  d       y)z,Sends response to concord's clearcut tables.z#Do you want to submit your response)prompt_stringzYour response is not recorded.N)r
   PromptContinuer   LogSurveyAnswersr	   errPrint)survey_instancesends     r   LogResponser$   /   s7    		"	"9
;$	!!/2GGMM23r   c                   &    e Zd ZdZed        Zd Zy)r   zInvoke a customer satisfaction survey for Google Cloud CLI.

  To permanently disable the survey prompt, run:

     $ gcloud config set survey/disable_prompts True

  ## EXAMPLES

  To launch the survey, run:

    $ {command}
  c                      y )N )parsers    r   ArgszSurvey.ArgsG   s    r   c                    t        j                         }|j                          t        t	        |            }t        |d      D ]1  \  }}dj                  ||      }t        j                  j                  |       |j                          t        j                  j                  d       |j                          t        |      }|t         j                  j                  j                   k(  r!t        j                  j                  d        y |t         j                  j                  j"                  k(  r0t        j                  j                  dj                  |             !|j%                  |       4 t'        |       y )N   z
Question {} of {}:

zExited the surveyzSkipped question {})r   r   PrintWelcomeMsglenlist	enumerateformatr	   r    r!   PrintQuestionwritePrintInstructionr   r   r   r   r   AnswerQuestionr$   )selfargsr"   num_of_questionsindexr   progress_msgr   s           r   Runz
Survey.RunK   s   **,O##%401$_a8x-44U<LMl	ggmmL!	ggmmD&&(#H-f	6==11==	=)*V]]33AAA+2259:f% 9  r   N)__name__
__module____qualname____doc__staticmethodr)   r;   r'   r   r   r   r   9   s      	 	!r   r   N)r?   
__future__r   r   r   googlecloudsdk.api_lib.surveyr   googlecloudsdk.callioper   !googlecloudsdk.command_lib.surveyr   googlecloudsdk.corer	   googlecloudsdk.core.consoler
   
_SURVEY_IDr   r$   Commandr   r'   r   r   <module>rI      sF    B &  ' 7 ( 4 # 2 
54%!T\\ %!r   