3 گa @s`dZddlZddlZddlZddlZddlZddlmZddlmZej e Z GdddZ dS)z.Collects and displays information to the user.N) configuration)utilc@s^eZdZdZdZdZdZejddZ e j ddd d Z de eedd d dZddddZdS)ReporterzCollects and displays information to the user. :ivar `queue.PriorityQueue` messages: Messages to be displayed to the user. r _msg_typezpriority text on_crashN)configreturncCstj|_||_dS)N)queueZ PriorityQueuemessagesr)selfrr /usr/lib/python3.6/reporter.py__init__s zReporter.__init__T)msgpriorityon_crashr cCs&|jj|j|||tjd|dS)aXAdds 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. zReporting to user: %sN)r Zputrloggerdebug)r rrrr r r add_message#s zReporter.add_message)r csJd}|jjsntjddk}tjj}|jjsF|r>tt j tdt j dd ddd}t j |j |j dddx|jjs$|jj}|jjr|j|jko|jsqp|s|jrp|r|j|jkr|jjstjjt jd}|jj}t|j|dt|d krptd jfd d |d dDqpW|rF|jj rFtjjt jdS)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. FrNzIMPORTANT NOTES:z -  )Zinitial_indentsubsequent_indentZbreak_long_wordsZbreak_on_hyphensr c3s|]}j|VqdS)N)fill).0line) next_wrapperr r \sz*Reporter.print_messages..z )r emptysysexc_infostdoutisattyrquietprintrZ ANSI_SGR_BOLDtextwrapZ TextWrapperrgetr HIGH_PRIORITYrwriteZANSI_SGR_RESETtext splitlinesrlenjoin)r Zbold_onZ no_exceptionZ first_wrapperrlinesr )rrprint_messages3sF       "zReporter.print_messages)T)__name__ __module__ __qualname____doc__r(ZMEDIUM_PRIORITYZ LOW_PRIORITY collections namedtuplerrZNamespaceConfigrstrintboolrr/r r r rrs r) r3r4Zloggingr r r&ZcertbotrrZ getLoggerr0rrr r r rs