From f8efc58597f09e2c14c67e20731249201e75e8f9 Mon Sep 17 00:00:00 2001 From: "RICART Michael (X)" Date: Tue, 20 Feb 2018 15:22:04 +0100 Subject: [PATCH] Work in progress for uConfigParser --- esp8266/uConfigParser.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/esp8266/uConfigParser.py b/esp8266/uConfigParser.py index 07ea309..1f8be91 100644 --- a/esp8266/uConfigParser.py +++ b/esp8266/uConfigParser.py @@ -1,10 +1,11 @@ -class RawConfigParser: +class ConfigParser: def __init__(self): - pass + self.config_dict = {} def sections(self): """Return a list of section names, excluding [DEFAULT]""" - pass + dict_to_return = [section for section in self.config_dict.keys() if not section in "DEFAULT"] + return dict_to_return def add_section(self, section): pass @@ -16,7 +17,14 @@ class RawConfigParser: pass def read(self, filename = None, fp = None): - pass + if not fp: + fp = open(filename) + self.config_dict = {line.replace('[','').replace(']',''):{} for line in fp.read()\ + if line.startswith('[') and line.endwith(']') + } + + + def get(self, section, option):