No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ini_files.py 514B

1234567891011121314151617
  1. from configparser import ConfigParser, MissingSectionHeaderError
  2. ## @brief Returns a dictionary from an ini file content
  3. # @param ini_file_path str
  4. # @return dict
  5. # @throw MissingSectionHeaderError
  6. # @todo Implement a better way to deal with this exception
  7. def ini_to_dict(ini_file_path):
  8. result = {}
  9. try:
  10. config = ConfigParser()
  11. config.read(ini_file_path)
  12. result = config.__dict__['_sections'].copy()
  13. except MissingSectionHeaderError as e:
  14. pass
  15. return result