U
    +c
                     @   s   d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlZdZdd	d
Z	dd Z
dd Zdd ZdddZdd Zdd Zdd Zdd ZdS )z3Formatting utilities for use in creating help text.    )absolute_import)division)print_function)formatting_windowsNz...   c                    s"   |  d}d fdd|D S )N
c                 3   s"   | ]}|rd   | n|V  qdS ) N ).0linespacesr	   3/tmp/pip-unpacked-wheel-1xt1w7un/fire/formatting.py	<genexpr>   s   zIndent.<locals>.<genexpr>)splitjoin)textr   linesr	   r   r   Indent   s    
r   c                 C   s   t j| dgdS )Nboldattrs	termcolorZcoloredr   r	   r	   r   Bold#   s    r   c                 C   s   t j| dgdS )NZ	underliner   r   r   r	   r	   r   	Underline'   s    r   c                 C   s   t t| S )N)r   r   r   r	   r	   r   BoldUnderline+   s    r    | P   c                 C   s   g }d}t | D ]\}}|t| d k}|r^t|t| |krJ||7 }q||  |}qt|t| t| |kr||| 7 }q||  || }q|| |S )zDJoins the items by the separator, wrapping lines at the given width.    )	enumeratelenappendrstrip)items	separatorwidthr   current_lineindexitemZis_final_itemr	   r	   r   WrappedJoin/   s    


r,   c                 C   s   t j| ddgdS )NZredr   )colorr   r   r   r	   r	   r   ErrorF   s    r.   c                 C   s8   |t tk r|}t | |kr | S | d|t t  t S )z)Truncate text from the end with ellipsis.N)r#   ELLIPSIS)r   available_spaceline_lengthr	   r	   r   EllipsisTruncateJ   s
    r2   c                 C   s^   |t tk r|}t | |k r | S |t t }t|d }|| }| d| t | | d  S )z-Truncates text from the middle with ellipsis.r   N)r#   r/   int)r   r0   r1   Zavailable_string_lenZfirst_half_lenZsecond_half_lenr	   r	   r   EllipsisMiddleTruncateT   s    r4   c                 C   s   d|  S )Nz"%s"r	   r   r	   r	   r   DoubleQuote`   s    r5   )r   )r   r   )__doc__
__future__r   r   r   Zfirer   r   r/   r   r   r   r   r,   r.   r2   r4   r5   r	   r	   r	   r   <module>   s   


