o
    5ti                     @   s`   d dl Z d dlZd dlmZmZ d dlZddlmZ ddlmZ ddl	m
Z
 G dd	 d	e
ZdS )
    N)AnyUnion   )import_error_msg_template   serialize_dp)TextTableWriterc                       sd   e Zd ZdZdZdeddf fddZedefdd	Z	ede
fd
dZdeddfddZ  ZS )YamlTableWriterz
    A table writer class for `YAML <https://yaml.org/>`__ format.

        :Example:
            :ref:`example-yaml-table-writer`
    yamlkwargsreturnNc                    s2   t  jdi | d| _t| j_ttj	| _
d S )NF )super__init__
is_paddingfloat_dp_extractor
float_typecopydeepcopydatapropertyNOT_QUOTING_FLAGS_quoting_flags)selfr   	__class__r   S/home/ubuntu/.local/lib/python3.10/site-packages/pytablewriter/writer/text/_yaml.pyr      s   zYamlTableWriter.__init__c                 C   s   | j S )N)FORMAT_NAMEr   r   r   r   format_name   s   zYamlTableWriter.format_namec                 C   s   dS )NFr   r   r   r   r   support_split_write"   s   z#YamlTableWriter.support_split_writec                    s   zddl }W n ty   ttd  w  jJ        j	r1 fdd j
D }ndd  j
D } jrJ |j j|idd n |j|dd W d   dS W d   dS 1 sgw   Y  dS )	zy
        |write_table| with
        YAML format.

        :Example:
            :ref:`example-yaml-table-writer`
        r   Nr   c                    s&   g | ]}t t jd d |D qS )c                 S      g | ]}t |qS r   r   .0value_dpr   r   r   
<listcomp>;       :YamlTableWriter.write_table.<locals>.<listcomp>.<listcomp>)dictzipheadersr$   value_dp_listr   r   r   r&   :   s    z/YamlTableWriter.write_table.<locals>.<listcomp>c                 S   s   g | ]	}d d |D qS )c                 S   r"   r   r   r#   r   r   r   r&   @   r'   r(   r   r,   r   r   r   r&   ?   s    F)default_flow_style)r   ImportErrorwarningswarnr   format_logger_verify_property_preprocessr+   _table_value_dp_matrix
table_name_write	safe_dump)r   r   r   matrixr   r   r   write_table&   s,   	
"zYamlTableWriter.write_table)__name__
__module____qualname____doc__r   r   r   propertystrr    boolr!   r;   __classcell__r   r   r   r   r
      s    r
   )r   r0   typingr   r   r   _commonr   r   _text_writerr	   r
   r   r   r   r   <module>   s    