o
    €ÏÀ
  ã                   @   sv   d Z ddlmZ ddlmZ ddlmZ ddlZG dd„ deƒZG dd	„ d	eƒZG d
d„ dej	ƒZ
G dd„ de
ƒZdS )z:Semantic text objects that are used for styled outputting.é    )Úabsolute_import)Údivision)Úunicode_literalsNc                   @   s>   e Zd ZdZddd„Zedd„ ƒZedd„ ƒZed	d
„ ƒZdS )ÚTextAttributesz%Attributes to use to style text with.Nc                 C   s   || _ || _|p	g | _dS )a?  Defines a set of attributes for a piece of text.

    Args:
      format_str: (str), string that will be used to format the text
        with. For example '[{}]', to enclose text in brackets.
      color: (Colors), the color the text should be formatted with.
      attrs: (Attrs), the attributes to apply to text.
    N)Ú_format_strÚ_colorÚ_attrs)ÚselfÚ
format_strÚcolorÚattrs© r   úC/tmp/google-cloud-sdk/lib/googlecloudsdk/core/console/style/text.pyÚ__init__   s   	zTextAttributes.__init__c                 C   ó   | j S ©N)r   ©r	   r   r   r   r
   (   ó   zTextAttributes.format_strc                 C   r   r   )r   r   r   r   r   r   ,   r   zTextAttributes.colorc                 C   r   r   )r   r   r   r   r   r   0   r   zTextAttributes.attrs)NNN)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr
   r   r   r   r   r   r   r      s    


r   c                   @   s2   e Zd ZdZddd„Zdd„ Zdd„ Zd	d
„ ZdS )Ú	TypedTextz8Text with a semantic type that will be used for styling.Nc                 C   s   || _ || _dS )a  String of text and a corresponding type to use to style that text.

    Args:
     texts: (list[str]), list of strs or TypedText objects
       that should be styled using text_type.
     text_type: (TextTypes), the semantic type of the text that
       will be used to style text.
    N)ÚtextsÚ	text_type)r	   r   r   r   r   r   r   8   s   	
zTypedText.__init__c                 C   s    d}| j D ]}|t|ƒ7 }q|S )Nr   )r   Úlen)r	   ÚlengthÚtextr   r   r   Ú__len__D   s   
zTypedText.__len__c                 C   s   | |g}t |ƒS r   ©r   ©r	   Úotherr   r   r   r   Ú__add__J   ó   zTypedText.__add__c                 C   s   || g}t |ƒS r   r    r!   r   r   r   Ú__radd__N   r$   zTypedText.__radd__r   )r   r   r   r   r   r   r#   r%   r   r   r   r   r   5   s    
r   c                   @   s   e Zd ZdZdd„ ZdS )Ú
_TextTypesz6Text types base class that defines base functionality.c                 G   s   t t|ƒ| ƒS )z,Returns a TypedText object using this style.)r   Úlist)r	   Úargsr   r   r   Ú__call__V   s   z_TextTypes.__call__N)r   r   r   r   r)   r   r   r   r   r&   S   s    r&   c                   @   s4   e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdS )Ú	TextTypesz5Defines text types that can be used for styling text.é   é   é   é   é   é   é   é   é	   N)r   r   r   r   ÚRESOURCE_NAMEÚURLÚ
USER_INPUTÚCOMMANDÚINFOÚURIÚOUTPUTÚ
PT_SUCCESSÚ
PT_FAILUREr   r   r   r   r*   [   s    r*   )r   Ú
__future__r   r   r   ÚenumÚobjectr   r   ÚEnumr&   r*   r   r   r   r   Ú<module>   s   