o
    ’ôjõ  ã                   @   sÀ   d dl Z d dlmZ d dlmZ d dlmZmZmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ eG dd„ dƒƒZG dd„ deeƒZG dd„ deƒZdS )é    N)Úabstractmethod)Ú	dataclass)ÚDictÚListÚOptional)Ú	Container)Úversion)Údeprecation_warning)ÚInputDefault)Ú
ObjectType)ÚHydraException)ÚPluginc                   @   sZ   e Zd ZU eed< eed< eed< eeee f ed< dZee	e
  ed< dZeed< dS )	ÚConfigResultÚproviderÚpathÚconfigÚheaderNÚdefaults_listFÚis_schema_source)Ú__name__Ú
__module__Ú__qualname__ÚstrÚ__annotations__r   r   r   r   r   r
   r   Úbool© r   r   ún/var/www/html/academy/tools/voices/clone/cosy-venv/lib/python3.10/site-packages/hydra/plugins/config_source.pyr      s   
 r   c                   @   s   e Zd ZdS )ÚConfigLoadErrorN)r   r   r   r   r   r   r   r      s    r   c                
   @   sZ  e Zd ZU eed< eed< dededdfdd„Zeedefdd„ƒƒZed	ede	fd
d„ƒZ
d	edefdd„Zed	edefdd„ƒZed	edefdd„ƒZedefdd„ƒZed	edee dee fdd„ƒZdefdd„Zdefdd„Zdee dededee ddf
dd„Zdefd d!„Zed"edefd#d$„ƒZed%edeeee f fd&d'„ƒZdS )(ÚConfigSourcer   r   ÚreturnNc                 C   s:   |  |  ¡ ¡stdƒ‚|| _|t|  ¡ d ƒd … | _d S )NzInvalid pathú://)Ú
startswithÚschemeÚ
ValueErrorr   Úlenr   )Úselfr   r   r   r   r   Ú__init__#   s   zConfigSource.__init__c                   C   ó   dS )z[
        :return: the scheme for this config source, for example file:// or pkg://
        Nr   r   r   r   r   r"   )   s   zConfigSource.schemeÚconfig_pathc                 C   ó   d S ©Nr   ©r%   r(   r   r   r   Úload_config1   ó   zConfigSource.load_configc                 C   s   |   |¡p	|  |¡S r*   )Úis_groupÚ	is_configr+   r   r   r   Úexists6   ó   zConfigSource.existsc                 C   r)   r*   r   r+   r   r   r   r.   9   r-   zConfigSource.is_groupc                 C   r)   r*   r   r+   r   r   r   r/   =   r-   zConfigSource.is_configc                 C   r'   )zU
        :return: True is this config source is pointing to a valid location
        Nr   ©r%   r   r   r   Ú	availableA   s   zConfigSource.availableÚresults_filterc                 C   r'   )a?  
        List items under the specified config path
        :param config_path: config path to list items in, examples: "", "foo", "foo/bar"
        :param results_filter: None for all, GROUP for groups only and CONFIG for configs only
        :return: a list of config or group identifiers (sorted and unique)
        Nr   )r%   r(   r4   r   r   r   ÚlistH   s   zConfigSource.listc                 C   s   t | ƒS r*   )Úreprr2   r   r   r   Ú__str__R   s   zConfigSource.__str__c                 C   s   d| j › d|  ¡ › d| j› �S )Nz	provider=z, path=r    )r   r"   r   r2   r   r   r   Ú__repr__U   s   zConfigSource.__repr__ÚfilesÚ	file_pathÚ	file_namec           	      C   sš   ddg}|   |¡}|  |¡}|r"|d u s|tjkr"||vr"| |¡ |rG||vrI|d u s1|tjkrK| d¡}|dkr@|d|… }| |¡ d S d S d S d S )NÚ__pycache__z__init__.pyÚ.éÿÿÿÿr   )r.   r/   r   ÚGROUPÚappendÚCONFIGÚrfind)	r%   r9   r:   r;   r4   Úfilteredr.   r/   Úlast_dotr   r   r   Ú_list_add_resultX   s&   

ÿ
ÿ
özConfigSource._list_add_resultc                 C   s   |   ¡ › d| j› �S )Nr    )r"   r   r2   r   r   r   Ú	full_patht   r1   zConfigSource.full_pathÚfilenamec                    sN   dg}t  d¡s| d¡ ˆ  d¡rtdƒ t‡ fdd„|D ƒƒs%ˆ d7 ‰ ˆ S )Nz.yamlz1.2z.ymlzPSupport for .yml files is deprecated. Use .yaml extension for Hydra config filesc                 3   s   � | ]}ˆ   |¡V  qd S r*   )Úendswith)Ú.0Úext©rG   r   r   Ú	<genexpr>€   s   € z4ConfigSource._normalize_file_name.<locals>.<genexpr>)r   Úbase_at_leastr@   rH   r	   Úany)rG   Úsupported_extensionsr   rK   r   Ú_normalize_file_namew   s   


ÿz!ConfigSource._normalize_file_nameÚconfig_textc                 C   sê   i }|   ¡ D ]d}| ¡ }t|ƒdkrqt d|¡rj| d¡ ¡ }t d|¡}ttdd„ |ƒƒ}t|ƒdk r=t	d|› d	�ƒ‚t|ƒdkrKt	d
|› d	�ƒ‚|d |d }}| ¡ }| ¡ }| 
d¡ri|||dd … < q d|vrsd |d< |S )Nr   z	^\s*#\s*@ú#ú c                 S   s   t | ƒdkS )Nr   )r$   )Úxr   r   r   Ú<lambda>�   s    z/ConfigSource._get_header_dict.<locals>.<lambda>é   z(Expected header format: KEY VALUE, got 'ú'zToo many components in 'é   ú@Úpackage)Ú
splitlinesÚstripr$   ÚreÚmatchÚlstripÚsplitr5   Úfilterr#   r!   )rQ   ÚresÚlineÚsplitsÚkeyÚvalr   r   r   Ú_get_header_dict„   s.   
€zConfigSource._get_header_dict)r   r   r   r   r   r&   Ústaticmethodr   r"   r   r,   r   r0   r.   r/   r3   r   r   r   r5   r7   r8   rE   rF   rP   r   rg   r   r   r   r   r      sH   
  	þýüû
ú$r   )r]   Úabcr   Údataclassesr   Útypingr   r   r   Ú	omegaconfr   Úhydrar   Ú#hydra._internal.deprecation_warningr	   Zhydra.core.default_elementr
   Úhydra.core.object_typer   Úhydra.errorsr   Zhydra.plugins.pluginr   r   ÚIOErrorr   r   r   r   r   r   Ú<module>   s   	