
    Ve                     B    d dl mZ d dlmZ ddl  ee      Zd Zd Zy)    )	getLogger)	load_yaml   )*c                    t         j                  d|         d| t           v r!| t           d   | t           d<   | t           d= nt         j                  d       d| t           v r| t           d   | t           d<   | t           d= d| v rd| d   | d   j                  d      <   d| t           d   v rxt        | t           d   d   v rc| t           d   d   t           }|j	                         D ]$  \  }}d	|v s|d	   d
v si ||<   |d|dg||   d<   & nt         j                  d       t         j                  d|         | S )a  
    Preprocess schema before validation for user's convenience

    Preprocessing includes:
    - renaming 'samples' to '_samples' since in the peppy.Project object
        _samples attribute holds the list of peppy.Samples objects.
    - adding array of strings entry for every string specified to accommodate
        subsamples in peppy.Project

    :param dict schema_dict: schema dictionary to preprocess
    :return dict: preprocessed schema
    zschema ori: config_configz!No config section found in schemasamples_samplesrequireditemstype)stringnumberbooleanarray)r   r   anyOfz"No samples section found in schemazschema processed: )_LOGGERdebugPROP_KEYindexr   )schema_dicts_propspropvals       +lib/python3.12/site-packages/eido/schema.pypreprocess_schemar   
   su    MML./;x((+6x+@+JHi(!(+9:K)),7,A),LHj)!),$  
#J'--i8 {8,Z88K1*=gFF!(+J7@JG$]]_ T	cS=S[4S%S$&GDM.1Gc3R-SGDM'*T
 	:;MM&{m45    c                     d }g }t        | t              r#t        j                  d|         t	        |       } t        | t
              st        dt        |               || |      S )a  
    Safely read schema from YAML-formatted file.

    If the schema imports any other schemas, they will be read recursively.

    :param str | Mapping schema: path to the schema file
        or schema in a dict form
    :return list[dict]: read schemas
    :raise TypeError: if the schema arg is neither a Mapping nor a file path or
        if the 'imports' sections in any of the schemas is not a list
    c                     d| v rCt        | d   t              r%| d   D ]  }|j                  t        |              nt	        d      |j                  |        |S )Nimportsz0In schema the 'imports' section has to be a list)
isinstancelistextendread_schema	TypeErrorappend)xlstschs      r   _recursively_read_schemasz.read_schema.<locals>._recursively_read_schemas@   sY    >!I,-Y< 1CJJ{3/01   RSS

1
r   zReading schema: zOschema has to be a dict, path to an existing file or URL to a remote one. Got: )r"   strr   r   r   dictr&   r   )schemar+   schema_lists      r   r%   r%   3   so     K&#(126"fd#L>#
 	
 %V[99r   N)	loggingr   peppy.utilsr   const__name__r   r   r%    r   r   <module>r5      s#     ! 
H
&R :r   