File: //home/arjun/projects/env/lib64/python3.10/site-packages/honcho/__pycache__/printer.cpython-310.pyc
o
we�
� @ s� d dl mZ d dlZddlmZ edd�ZG dd� de�Zd d
� Zdd� Z erBzd dl
Z
W n ey; d
d� Z Y dS w e
�� dS dS )� )�
namedtupleN� )�
ON_WINDOWS�Messageztype data time name colourc @ s. e Zd ZdZejddddfdd�Zdd� Zd S )
�Printerz�
Printer is where Honcho's user-visible output is defined. A Printer
instance receives typed messages and prints them to its output (usually
STDOUT) in the Honcho format.
z%H:%M:%Sr Tc C sL || _ || _|| _|| _|| _z | j �� | _W d S ty% d| _Y d S w )NF)�output�time_format�width�colour�prefix�isatty�_colours_supported�AttributeError)�selfr r r r
r � r �G/home/arjun/projects/env/lib/python3.10/site-packages/honcho/printer.py�__init__ s �zPrinter.__init__c C s� |j dkr td��|jd ur|jnd}|�| j�}|r|d7 }t|jt�r-|j�dd�}n|j}|� � D ].}d}| j
rX|j�| j
�}dj||d�}| jrX| jrX|jrXt|j|�}t|| | jd d
� q4d S )N�linez0Printer can only process messages of type "line"� � zutf-8�replacez{time} {name}| )�time�nameT)�file�flush)�type�RuntimeErrorr �ljustr �
isinstance�data�bytes�decode�
splitlinesr r �strftimer �formatr
r
�_colour_string�printr )r �messager �stringr r �time_formattedr r r �write% s$
�z
Printer.writeN)�__name__�
__module__�__qualname__�__doc__�sys�stdoutr r* r r r r r s
�r c C s
d� | �S )Nz[{0}m)r$ )�coder r r �_ansi@ s
r2 c C s d� td�t| �|td��S )Nz{0}{1}{2}{3}r )r$ r2 �r
�sr r r r% D s r% c C s |S )Nr r3 r r r r% O s )
�collectionsr r/ �compatr r �objectr r2 r% �colorama�ImportError�initr r r r �<module> s
7��