o
    €Ïã  ã                   @   sR   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G dd„ dejƒZ	dS )	z.Object representation format resource printer.é    )Úabsolute_import)Údivision)Úunicode_literals)Úresource_printer_baseNc                       s*   e Zd ZdZ‡ fdd„Zddd„Z‡  ZS )ÚObjectPrintera  Prints the object representation of each item in a list.

  Bypasses JSON-serialization and prints the object representation of each
  resource.

  Printer attributes:
    separator: The line printed between resources.
    terminator: The line printed after each resource.
  c                    sJ   t t| ƒj|ddi|¤Ž d| _| j d¡| _| j d¡| _dd„ | _d S )NÚ
by_columnsTÚ	separatorÚ
terminatorc                 S   s   | S )N© )Úxr
   r
   úH/tmp/google-cloud-sdk/lib/googlecloudsdk/core/resource/object_printer.pyÚ<lambda>+   s    z(ObjectPrinter.__init__.<locals>.<lambda>)	Úsuperr   Ú__init__Ú_first_recordÚ
attributesÚgetÚ
_separatorÚ_terminatorÚ_process_record)ÚselfÚargsÚkwargs©Ú	__class__r
   r   r   &   s
   zObjectPrinter.__init__Fc                 C   s\   | j rd| _ n|r| jdur| j | j¡ | j t |¡¡ | jdur,| j | j¡ dS dS )z“Immediately prints the given record using the object representation.

    Args:
      record: An object.
      delimit: Display the separator.
    FN)r   r   Ú_outÚPrintÚwriteÚsixÚ	text_typer   )r   ÚrecordÚdelimitr
   r
   r   Ú
_AddRecord-   s   
ÿzObjectPrinter._AddRecord)F)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r"   Ú__classcell__r
   r
   r   r   r      s    
r   )
r&   Ú
__future__r   r   r   Úgooglecloudsdk.core.resourcer   r   ÚResourcePrinterr   r
   r
   r
   r   Ú<module>   s   