o
    uJAf2
                     @  s   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r3ddlmZ dd	lmZ G d
d deZdddZdS )    )annotationsN   )ExtensionModule
ModuleInfo   )mesonlib)noKwargstyped_pos_args)Interpreter)ModuleStatec                      sX   e Zd ZeddddZd fddZedddZee	de
ejfdddZ  ZS )KeyvalModuleZkeyvalz0.55.0z0.56.0)
stabilizedinterp'Interpreter'c                   s"   t  | | jd| ji d S )Nload)super__init__methodsupdater   )selfr   	__class__ >/usr/lib/python3.10/site-packages/mesonbuild/modules/keyval.pyr      s   
zKeyvalModule.__init__path_to_configstrreturnT.Dict[str, str]c              
   C  s   i }zOt | dd>}|D ]1}d|v r|d}|d | }| }z
|dd\}}W n	 ty4   Y qw | || < qW d    W |S 1 sJw   Y  W |S  tyh } ztd|  d| d }~ww )Nzutf-8)encoding#=r   zFailed to load z: )openindexstripsplit
ValueErrorOSErrorr   MesonException)r   resultflineZcomment_idxnamevaler   r   r   
_load_file%   s.   
zKeyvalModule._load_filezkeyval.loadstate'ModuleState'args T.Tuple['mesonlib.FileOrString']kwargsT.Dict[str, T.Any]c                 C  sl   |d }d}t |tjr|p|j}|| jjj| jjj}n
t	j
| jjj|}|s1| 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   r/   r1   r3   sr7   r   r   r   r   9   s   

zKeyvalModule.load)r   r   )r   r   r   r   )r/   r0   r1   r2   r3   r4   r   r   )__name__
__module____qualname__r   INFOr   staticmethodr.   r   r	   r   r   r6   r   __classcell__r   r   r   r   r      s    r   r   r   r   c                 C  s   t | S )N)r   )r   r   r   r   
initializeJ   s   rI   )r   r   r   r   )
__future__r   r=   typingT r   r   r   interpreterbaser   r	   TYPE_CHECKINGr9   r
   r   r   rI   r   r   r   r   <module>   s   /