
    MZeZ	                        d Z ddlmZ ddl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	Z G d
 de      Zy)4Source for INI configuration files via configparser.    )annotations)ConfigParserSectionProxy)Path)Dict)Source)Key)find_config_filec                    t        |      dk(  r|D ]
  }||   | |<    y |d   }| j                  |i        t        | |   t              sJ t	        | |   |dd  |       y )Nr      )len
setdefault
isinstancer   _add_split_to_dict)desttable_to_addtable	table_keyfirsts        :/usr/lib/python3/dist-packages/pytoolconfig/sources/ini.pyr   r      sr    
 <A 	/I#I.DO	/ Qr"$u+t,,,4;QR(8%@    c                  ^    e Zd ZU dZded<   ded<   ded<   	 d	 	 	 	 	 	 	 	 	 dd	Zdd
ZddZy)	IniConfigr   r   _configstrname
str | NonedescriptionNc                n    t        ||      | _        || _        || _        || _        t               | _        y)a  Initialize the Ini Configuration.

        :param working_directory: the working directory to search.
        :param filename: the filename to search for.
        :param base_table: The table to search for.
            The file will only be used if this is present.
            The base_table will not be included in the parsed output.
        :param description: The description used in documentation.
        N)r   file
base_tabler   r   r   r   )selfworking_directoryfilenamer"   r   s        r   __init__zIniConfig.__init__$   s2      %%6A	$	&#~r   c                    | j                   y| j                  j                  | j                   j                                | j                  D ]'  }|j	                  d      }|d   | j
                  k(  s' y y)NF.r   T)r!   r   read_string	read_textsplitr"   )r#   r   r+   s      r   _readzIniConfig._read:   sg    99  !4!4!67\\ 	EKK$EQx4??*	 r   c                    | j                         syi }| j                  D ]C  }|j                  d      }|d   | j                  k(  s't	        ||dd | j                  |          E |S )zParse the INI file.Nr(   r   r   )r,   r   r+   r"   r   )r#   outputr   r+   s       r   parsezIniConfig.parseD   sh    zz|!#\\ 	KEKK$EQx4??*"659dll56IJ	K r   )N)
r$   r   r%   r   r"   r   r   r   returnNone)r0   bool)r0   zdict[str, Key] | None)__name__
__module____qualname____doc____annotations__r&   r,   r/    r   r   r   r      sZ    >
I #'&& & 	&
  & 
&,	r   r   N)r   zdict[str, Key]r   z	list[str]r   r   r0   r1   )r6   
__future__r   configparserr   r   pathlibr   typingr   pytoolconfig.sources.sourcer	   pytoolconfig.typesr
   pytoolconfig.utilsr   r   r   r8   r   r   <module>r@      sW    : " 3   . " /A
AA A 
	A1 1r   