o
    tyij                     @   s|   d dl mZmZ d dlmZmZ d dlmZ d dlm	Z	 d dl
mZmZmZmZmZmZ dd Zdd	 ZG d
d deZdS )    )CommentedSeqCommentedMap)FixedSeqMap)	Validator)YAMLSerializationError)Bool	EmptyDict	EmptyListFloatIntStrc                 C   sB   t | trtdd |  D S t | trtdd | D S t S )Nc                 S   s   i | ]	\}}|t |qS  schema_from_document.0keyvaluer   r   [/home/ubuntu/maya3_transcribe/venv/lib/python3.10/site-packages/strictyaml/any_validator.py
<dictcomp>   s    z(schema_from_document.<locals>.<dictcomp>c                 S   s   g | ]}t |qS r   r   r   itemr   r   r   
<listcomp>   s    z(schema_from_document.<locals>.<listcomp>)
isinstancer   r   itemsr   r   r   )documentr   r   r   r      s   

r   c                    s   t | tr!t| dkr rt S tdt fdd|  D S t | tr@t| dkr5 r1t S tdt	 fdd| D S t | t
rHt S t | trPt S t | trXt S t S )Nr   zEEmpty dicts are not serializable to StrictYAML unless schema is used.c                    s   i | ]
\}}|t | qS r   schema_from_datar   allow_emptyr   r   r      s    z$schema_from_data.<locals>.<dictcomp>zEEmpty lists are not serializable to StrictYAML unless schema is used.c                    s   g | ]}t | qS r   r   r   r   r   r   r   %   s    z$schema_from_data.<locals>.<listcomp>)r   dictlenr	   r   r   r   listr
   r   boolr   intr   floatr   r   )datar    r   r   r   r      s2   




r   c                   @   s.   e Zd ZdZdd Zd
ddZedd Zd	S )AnyzG
    Validates any YAML and returns simple dicts/lists of strings.
    c                 C   s   t |j|S N)r   contents)selfchunkr   r   r   validate5   s   zAny.validateFc                 C   s   t ||d|S )z
        Args:
            allow_empty (bool): True to allow EmptyDict and EmptyList in the
                    schema generated from the data.
        r   )r   to_yaml)r+   r'   r    r   r   r   r.   8   s   zAny.to_yamlc                 C   s   t  S r)   )r   )r+   r   r   r   key_validator@   s   zAny.key_validatorN)F)__name__
__module____qualname____doc__r-   r.   propertyr/   r   r   r   r   r(   0   s    
r(   N)strictyaml.ruamel.commentsr   r   strictyaml.compoundr   r   strictyaml.validatorsr   strictyaml.exceptionsr   strictyaml.scalarr   r	   r
   r   r   r   r   r   r(   r   r   r   r   <module>   s     