3
گa
@ s` d Z ddlZddlZddlZddlZddlZddlmZ ddlmZ ej e
ZG dd dZdS )z.Collects and displays information to the user. N)
configuration)utilc @ s^ e Zd ZdZdZdZdZejddZ e
jddd d
Zde
eeddd
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)configreturnc C s t j | _|| _d S )N)queueZ
PriorityQueuemessagesr )selfr r
/usr/lib/python3.6/reporter.py__init__ s
zReporter.__init__T)msgpriorityon_crashr c C sF | j | ko| jkn s t| jj| j||| tjd| dS )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.
zReporting to user: %sN)
HIGH_PRIORITYLOW_PRIORITYAssertionErrorr Zputr loggerdebug)r r r r r
r
r add_message# s zReporter.add_message)r c sJ d}| j j sntj d dk}tjj }| jjsF|r>tt j
td tjdd
ddd}tj|j
|j
ddd x| j j s$| j j }| jjr|j| jko|jsqp|s|jrp|r|j| jkr| jjstjjt j d}|jj }t|j|d t|d krptd
j fdd|d d D qpW |rF| jj rFtjjt j dS )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 NzIMPORTANT NOTES:z - )Zinitial_indentsubsequent_indentZbreak_long_wordsZbreak_on_hyphensr
c 3 s | ]} j |V qd S )N)fill).0line)next_wrapperr
r