Skip to content

Instantly share code, notes, and snippets.

@belyaev-pa
Last active July 8, 2019 14:22
Show Gist options
  • Save belyaev-pa/9f95274acfe970f05da3bd0ad2d9f838 to your computer and use it in GitHub Desktop.
Save belyaev-pa/9f95274acfe970f05da3bd0ad2d9f838 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import ConfigParser
def parse_conf(conf_file_path):
"""
Функция парсинга конфиг файла
одноименные ключи будут затерты, будет взят последний
:param conf_file_path: путь до файла
:return: сформированный словарь настроек
"""
config = ConfigParser.ConfigParser()
config.read(conf_file_path)
config_dict = dict()
for section in config.sections():
section_dict = {key: value for (key, value) in config.items(section)}
config_dict.update(section_dict)
return config_dict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment