ó
Á£ô_c           @  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 ƒ d e f d „  ƒ  Yƒ Z d S(	   s.   Collects and displays information to the user.iÿÿÿÿ(   t   print_functionN(   t   queue(   t
   interfaces(   t   utilt   Reporterc           B  sP   e  Z d  Z d Z d Z d Z e j d d ƒ Z d „  Z	 e
 d „ Z d „  Z RS(	   s   Collects and displays information to the user.

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

    i    i   i   t   ReporterMsgs   priority text on_crashc         C  s   t  j ƒ  |  _ | |  _ d  S(   N(   R   t   PriorityQueuet   messagest   config(   t   selfR   (    (    s>   /usr/lib/python2.7/site-packages/certbot/_internal/reporter.pyt   __init__$   s    c         C  s[   |  j  | k o |  j k n s( t ‚ |  j j |  j | | | ƒ ƒ t j d | ƒ d S(   sX  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.

        s   Reporting to user: %sN(   t   HIGH_PRIORITYt   LOW_PRIORITYt   AssertionErrorR   t   putt	   _msg_typet   loggert   debug(   R	   t   msgt   priorityt   on_crash(    (    s>   /usr/lib/python2.7/site-packages/certbot/_internal/reporter.pyt   add_message(   s    (c      	     só  t  } |  j j ƒ  sº t j ƒ  d d k } t j j ƒ  } |  j j	 si | r\ t
 t j ƒ n  t
 d ƒ n  t j d d d d d t  d	 t  ƒ } t j d | j d | j d t  d	 t  ƒ ‰  n  x	|  j j ƒ  sÅ|  j j ƒ  } |  j j	 r| j |  j k oÿ | j sq½ qn  | s| j r½ | r]| j |  j k r]|  j j	 s]t j j t j ƒ t  } q]n  | j j ƒ  } t
 | j | d ƒ ƒ t | ƒ d
 k rÂt
 d j ‡  f d †  | d
 Dƒ ƒ ƒ qÂq½ q½ W| rï|  j j	 rït j j t j ƒ n  d S(   s¶   Prints 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.

        i    s   IMPORTANT NOTES:t   initial_indents    - t   subsequent_indentt    i   t   break_long_wordst   break_on_hyphensi   s   
c         3  s   |  ] } ˆ  j  | ƒ Vq d  S(   N(   t   fill(   t   .0t   line(   t   next_wrapper(    s>   /usr/lib/python2.7/site-packages/certbot/_internal/reporter.pys	   <genexpr>a   s    Ns      (   t   FalseR   t   emptyt   syst   exc_infot   Nonet   stdoutt   isattyR   t   quiett   printR   t   ANSI_SGR_BOLDt   textwrapt   TextWrapperR   t   getR   R   R   t   writet   ANSI_SGR_RESETt   textt
   splitlinesR   t   lent   join(   R	   t   bold_ont   no_exceptiont   first_wrapperR   t   lines(    (   R   s>   /usr/lib/python2.7/site-packages/certbot/_internal/reporter.pyt   print_messages8   sF    							((   t   __name__t
   __module__t   __doc__R   t   MEDIUM_PRIORITYR   t   collectionst
   namedtupleR   R
   t   TrueR   R6   (    (    (    s>   /usr/lib/python2.7/site-packages/certbot/_internal/reporter.pyR      s   	(   R9   t
   __future__R    R;   t   loggingR!   R)   t	   six.movesR   t   zope.interfacet   zopet   certbotR   R   t	   getLoggerR7   R   t	   interfacet   implementert	   IReportert   objectR   (    (    (    s>   /usr/lib/python2.7/site-packages/certbot/_internal/reporter.pyt   <module>   s   