uHodor/esp8266/uConfigParser.py

49 lines
1.3 KiB
Python
Raw Normal View History

2018-02-20 15:22:04 +01:00
class ConfigParser:
2018-02-16 01:03:02 +01:00
def __init__(self):
2018-02-20 15:22:04 +01:00
self.config_dict = {}
2018-02-16 01:03:02 +01:00
def sections(self):
"""Return a list of section names, excluding [DEFAULT]"""
2018-02-20 15:22:04 +01:00
dict_to_return = [section for section in self.config_dict.keys() if not section in "DEFAULT"]
return dict_to_return
2018-02-16 01:03:02 +01:00
def add_section(self, section):
pass
def has_section(self, section):
pass
def options(self, section):
pass
def read(self, filename = None, fp = None):
2018-02-20 15:22:04 +01:00
if not fp:
fp = open(filename)
self.config_dict = {line.replace('[','').replace(']',''):{} for line in fp.read()\
if line.startswith('[') and line.endwith(']')
}
2018-02-16 01:03:02 +01:00
def get(self, section, option):
def items(self, section):
def getboolean(self, section, option):
def has_option(self, section, option):
"""Check for the existence of a given option in a given section."""
def set(self, section, option, value=None):
"""Set an option."""
def write(self, fp):
"""Write an .ini-format representation of the configuration state."""
def remove_option(self, section, option):
"""Remove an option."""
def remove_section(self, section):
"""Remove a file section."""