a
    ¬ò¶hÛ  ã                   @   s.   d dl Z d dlmZ G dd„ dƒZdd„ ZdS )é    N)Úpathc                   @   s   e Zd ZdZdd„ ZdS )ÚdataSourcesInfoz¸
    A class to parse and store information from a YAML file containing observations data.

    Attributes:
        tab (dict): A dictionary to store the parsed observations data.
    c                 C   s˜   t  t  t¡d¡}t|dƒ�}t |¡| _W d  ƒ n1 s>0    Y  i | _| jd D ]:}|d }i | j|< |d D ]}|d }|| j| |< qvqXdS )zx
        The constructor for dataSourcesInfo class. Reads from a YAML file and initializes the 'tab' attribute.
        z	table.ymlÚrNZobservationsÚkxÚdetailsÚvar)	r   ÚjoinÚdirnameÚ__file__ÚopenÚyamlZ	safe_loadÚdataÚtab)ÚselfZ	yaml_fileÚfileZobservationr   Zdetailr   © r   ú5/home/caroline.viezel/readDiag/gsidiag/datasources.pyÚ__init__   s    *
zdataSourcesInfo.__init__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r      s   r   c                 C   sÒ   t ƒ }| |jv r¦||j|  v rt||j|  | v rB|j|  | | S td|ƒ tdƒ |j|  | D ]}td|ƒ qbqÎtd|d| ƒ tdƒ |j|  D ]}td|ƒ q”n(td| ƒ tdƒ |jD ]}td|ƒ q¾dS )aU  
    Retrieves information for a specified feature based on the kx and variable.

    Args:
        kx (int): The kx value to look up.
        var (str): The variable to look up.
        feature (str): The specific feature to retrieve information about.

    Returns:
        The value of the requested feature if found, otherwise None.
    zInvalid Feature request:zTry using one of:z	*ZVariablezdoesn't exist in kxzInvalid kx request:N)r   r   Úprint)r   r   ÚfeatureZdataInfoÚitemr   r   r   Ú
getVarInfo   s"    



r   )r   Úosr   r   r   r   r   r   r   Ú<module>   s   