
    x[h                     \    d dl Z d dlZd dlmZ  ej                  e      Z G d dee      Zy)    N)ConfigSourcec                   (    e Zd ZdZd Zd Zd Zd Zy)
ConfigFilez>ConfigFile module to load the content from a specified source.c                 &    | j                  |       y )N)_loadConfigFile)selffilenames     R/usr/lib/python3/dist-packages/cloudinit/sources/helpers/vmware/imc/config_file.py__init__zConfigFile.__init__   s    X&    c                     |j                         }|j                         }|j                  d      sd|v rd}nd}|rt        j                  d||       nt        j                  d|       || |<   y)z
        Inserts a Key Value pair.

        Keyword arguments:
        key -- The key to insert
        val -- The value to insert for the key

        -z|-FTzADDED KEY-VAL :: '%s' = '%s'z+ADDED KEY-VAL :: '%s' = '*****************'N)strip
startswithloggerdebug)r   keyvalcanLogs       r
   
_insertKeyzConfigFile._insertKey   sd     iikiik>>#$#+FF LL7cBLLFLS	r   c                 h   t         j                  d|       t        j                         }t        |_        |j                  |       | j                          |j                         D ]I  }t         j                  d|       |j                  |      D ]  \  }}| j                  |dz   |z   |        K y)a%  
        Parses properties from the specified config file.

        Any previously available properties will be removed.
        Sensitive data will not be logged in case the key starts
        from '-'.

        Keyword arguments:
        filename - The full path to the config file.
        zParsing the config file %s.zFOUND CATEGORY = '%s'|N)r   infoconfigparserConfigParserstroptionxformreadclearsectionsr   itemsr   )r   r	   configcategoryr   values         r
   r   zConfigFile._loadConfigFile/   s     	18<**, H

) 	=HLL0(;$ll84 =
U3 4e<=	=r   c                 b    t        | D cg c]  }|j                  |      s| c}      S c c}w )z
        Return the total count of keys that start with the specified prefix.

        Keyword arguments:
        prefix -- prefix of the key
        )lenr   )r   prefixr   s      r
   get_count_with_prefixz ConfigFile.get_count_with_prefixH   s(     4BC3>>&+ACBCCBs   ,,N)__name__
__module____qualname____doc__r   r   r   r(    r   r
   r   r      s    H'2=2Dr   r   )	r   logging2cloudinit.sources.helpers.vmware.imc.config_sourcer   	getLoggerr)   r   dictr   r-   r   r
   <module>r2      s2      K			8	$?Dt ?Dr   