x[h\ddlZddlZddlmZejeZGddeeZy)N) ConfigSourcec(eZdZdZdZdZdZdZy) ConfigFilez>ConfigFile module to load the content from a specified source.c&|j|y)N)_loadConfigFile)selffilenames R/usr/lib/python3/dist-packages/cloudinit/sources/helpers/vmware/imc/config_file.py__init__zConfigFile.__init__s X&c|j}|j}|jdsd|vrd}nd}|rtjd||ntjd||||<y)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 startswithloggerdebug)rkeyvalcanLogs r _insertKeyzConfigFile._insertKeysdiikiik >># $#+FF  LL7c B LLF LS r chtjd|tj}t|_|j ||j|jD]I}tjd||j|D]\}}|j|dz|z|Ky)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) rinfo configparser ConfigParserstr optionxformreadclearsectionsritemsr)rr configcategoryrvalues r rzConfigFile._loadConfigFile/s  18<**,  H ) =H LL0( ;$ll84 = U3 4e< = =r cbt|Dcgc]}|j|s|c}Scc}w)z Return the total count of keys that start with the specified prefix. Keyword arguments: prefix -- prefix of the key )lenr)rprefixrs r get_count_with_prefixz ConfigFile.get_count_with_prefixHs(4BC3>>&+ACBCCBs,,N)__name__ __module__ __qualname____doc__r rrr(r r rrsH'2=2Dr r) rlogging2cloudinit.sources.helpers.vmware.imc.config_sourcer getLoggerr)rdictrr-r r r2s2K   8 $?Dt?Dr