3 \¼meŸã@s<ddlZddlZddlmZejeƒZGdd„deeƒZdS)éN)Ú ConfigSourcec@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) Ú ConfigFilez>ConfigFile module to load the content from a specified source.cCs|j|ƒdS)N)Ú_loadConfigFile)ÚselfÚfilename©rú!/usr/lib/python3.6/config_file.pyÚ__init__szConfigFile.__init__cCsX|jƒ}|jƒ}|jdƒs"d|kr(d}nd}|r@tjd||ƒn tjd|ƒ|||<dS)z˜ Inserts a Key Value pair. Keyword arguments: key -- The key to insert val -- The value to insert for the key ú-z|-FTzADDED KEY-VAL :: '%s' = '%s'z+ADDED KEY-VAL :: '%s' = '*****************'N)ÚstripÚ startswithÚloggerÚdebug)rÚkeyÚvalZcanLogrrrÚ _insertKeys  zConfigFile._insertKeycCsztjd|ƒtjƒ}t|_|j|ƒ|jƒxH|jƒD]<}tj d|ƒx*|j |ƒD]\}}|j |d||ƒqRWq6WdS)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. zParsing the config file %s.zFOUND CATEGORY = '%s'ú|N) r ÚinfoÚ configparserZ ConfigParserÚstrZ optionxformÚreadÚclearZsectionsrÚitemsr)rrÚconfigÚcategoryrÚvaluerrrr/s   zConfigFile._loadConfigFilecst‡fdd„|DƒƒS)z– Return the total count of keys that start with the specified prefix. Keyword arguments: prefix -- prefix of the key csg|]}|jˆƒr|‘qSr)r )Ú.0r)Úprefixrrú Osz4ConfigFile.get_count_with_prefix..)Úlen)rrr)rrÚget_count_with_prefixHsz ConfigFile.get_count_with_prefixN)Ú__name__Ú __module__Ú __qualname__Ú__doc__r rrr rrrrrs r) rZloggingZ2cloudinit.sources.helpers.vmware.imc.config_sourcerZ getLoggerr!r ÚdictrrrrrÚs