
    e2
                        d dl mZ d dlZd dlZddlmZmZ ddlmZ ddl	m
Z
mZ ej                  rddlmZ dd	lmZ  G d
 de      ZddZy)    )annotationsN   )ExtensionModule
ModuleInfo   )mesonlib)noKwargstyped_pos_args)Interpreter)ModuleStatec                       e Zd Z eddd      Zd	 fdZed
d       Ze e	de
ej                  f      dd              Z xZS )KeyvalModulekeyvalz0.55.0z0.56.0)
stabilizedc                r    t         |   |       | j                  j                  d| j                  i       y )Nload)super__init__methodsupdater   )selfinterp	__class__s     ;/usr/lib/python3/dist-packages/mesonbuild/modules/keyval.pyr   zKeyvalModule.__init__   s0     DII
 	    c                   i }	 t        | d      5 }|D ]c  }d|v r|j                  d      }|d | }|j                         }	 |j                  dd      \  }}|j                         ||j                         <   e 	 d d d        |S # t        $ r Y |w xY w# 1 sw Y   |S xY w# t
        $ r }t        j                  d|  d|       d }~ww xY w)Nzutf-8)encoding#=r   zFailed to load z: )openindexstripsplit
ValueErrorOSErrorr   MesonException)path_to_configresultflinecomment_idxnamevales           r   
_load_filezKeyvalModule._load_file%   s    #%	Snw7 
71 	7Dd{&*jjo#L[1::<D!$(JJsA$6	c ,/99;F4::<(	7
7  & ! !
7   	S))ON;K2aS*QRR	SsX   B! 0BB#B;B! 	BBBBBB! B! !	C
*CC
zkeyval.loadc                   |d   }d}t        |t        j                        r_|xs |j                  }|j	                  | j
                  j                  j                  | j
                  j                  j                        }n>t        j                  j                  | j
                  j                  j                  |      }|s%| j
                  j                  j                  |       | j                  |      S )Nr   F)
isinstancer   Fileis_builtabsolute_pathinterpreterenvironment
source_dir	build_dirospathjoinbuild_def_filesaddr/   )r   stateargskwargssr3   s         r   r   zKeyvalModule.load9   s     Ga'-1::H 0 0 < < G GIYIYIeIeIoIopAT--99DDaHA,,003q!!r   )r   'Interpreter')r'   strreturnT.Dict[str, str])r>   z'ModuleState'r?   z T.Tuple['mesonlib.FileOrString']r@   zT.Dict[str, T.Any]rD   rE   )__name__
__module____qualname__r   INFOr   staticmethodr/   r	   r
   rC   r   r2   r   __classcell__)r   s   @r   r   r      sV    hX>D  & MC#78" 9 "r   r   c                    t        |       S )N)r   )r   s    r   
initializerM   J   s    r   )r   rB   rD   r   )
__future__r   r9   typingT r   r   r   interpreterbaser	   r
   TYPE_CHECKINGr5   r   r   r   rM    r   r   <module>rU      s8    # 	  )  6??),"? ,"^ r   