
\\                 @   s   d  Z  d d l m Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l	 Z
 d d l m Z d d l m Z e j e  Z e
 j j e j  Gd d   d e   Z d S)	z.Collects and displays information to the user.    )print_functionN)queue)
interfaces)utilc               @   sa   e  Z d  Z d Z d Z d Z d Z e j d d  Z	 d d   Z
 d	 d
 d  Z d d   Z d S)ReporterzCollects and displays information to the user.

    :ivar `queue.PriorityQueue` messages: Messages to be displayed to
        the user.

    r         ZReporterMsgzpriority text on_crashc             C   s   t  j   |  _ | |  _ d  S)N)r   ZPriorityQueuemessagesconfig)selfr
    r   2/usr/lib/python3/dist-packages/certbot/reporter.py__init__%   s    zReporter.__init__Tc             C   s[   |  j  | k o |  j k n s( t  |  j j |  j | | |   t j d |  d S)aX  Adds msg to the list of messages to be printed.

        :param str msg: Message to be displayed to the user.

        :param int priority: One of `HIGH_PRIORITY`, `MEDIUM_PRIORITY`,
            or `LOW_PRIORITY`.

        :param bool on_crash: Whether or not the message should be
            printed if the program exits abnormally.

        zReporting to user: %sN)HIGH_PRIORITYLOW_PRIORITYAssertionErrorr	   Zput	_msg_typeloggerdebug)r   msgpriorityon_crashr   r   r   add_message)   s    (zReporter.add_messagec          	      s  d } |  j  j   s t j   d d k } t j j   } |  j j sc | rY t t	 j
  t d  t j d d d d d
 d d d  } t j d | j d | j d
 d d d    x |  j  j   s|  j  j   } |  j j r | j |  j k o | j s q | s| j r | rH| j |  j k rH|  j j sHt j j t	 j  d } | j j   } t | j | d   t |  d k r t d j   f d d   | d d  D   q W| r|  j j rt j j t	 j  d S)zPrints messages to the user and clears the message queue.

        If there is an unhandled exception, only messages for which
        ``on_crash`` is ``True`` are printed.

        Fr   NzIMPORTANT NOTES:Zinitial_indentz - subsequent_indent    Zbreak_long_wordsZbreak_on_hyphensr   
c             3   s   |  ] }   j  |  Vq d  S)N)fill).0line)next_wrapperr   r   	<genexpr>b   s    z*Reporter.print_messages.<locals>.<genexpr>z   )r	   emptysysexc_infostdoutisattyr
   quietprintr   ZANSI_SGR_BOLDtextwrapZTextWrapperr   getr   r   r   writeZANSI_SGR_RESETtext
splitlinesr   lenjoin)r   Zbold_onZno_exceptionZfirst_wrapperr   linesr   )r    r   print_messages9   sF    
							+zReporter.print_messagesN)__name__
__module____qualname____doc__r   ZMEDIUM_PRIORITYr   collections
namedtupler   r   r   r1   r   r   r   r   r      s   r   )r5   Z
__future__r   r6   Zloggingr#   r)   Z	six.movesr   Zzope.interfacezopeZcertbotr   r   Z	getLoggerr2   r   Z	interfaceZimplementerZ	IReporterobjectr   r   r   r   r   <module>   s   