Merge branch '1-comment-code-help-functions' into 'master'

Resolve "comment code (help functions)"

Closes #1

See merge request !1
This commit is contained in:
Milka64 2018-02-23 15:49:39 +00:00
commit f08049b4a6

View file

@ -8,20 +8,24 @@ class ConfigParser:
return dict_to_return return dict_to_return
def add_section(self, section): def add_section(self, section):
"""Create a new section in the configuration."""
self.config_dict[section] = {} self.config_dict[section] = {}
def has_section(self, section): def has_section(self, section):
"""Indicate whether the named section is present in the configuration."""
if section in self.config_dict.keys(): if section in self.config_dict.keys():
return True return True
else: else:
return False return False
def options(self, section): def options(self, section):
"""Return a list of option names for the given section name."""
if not section in self.config_dict: if not section in self.config_dict:
raise raise
return self.config_dict[section].keys() return self.config_dict[section].keys()
def read(self, filename=None, fp=None): def read(self, filename=None, fp=None):
"""Read and parse a filename or a list of filenames."""
if not fp and not filename: if not fp and not filename:
print("ERROR : no filename and no fp") print("ERROR : no filename and no fp")
raise raise
@ -60,6 +64,7 @@ class ConfigParser:
self.config_dict[section][option] = values self.config_dict[section][option] = values
def get(self, section, option): def get(self, section, option):
"""Get value of a givenoption in a given section."""
if not self.has_section(section) \ if not self.has_section(section) \
or not self.has_option(section,option): or not self.has_option(section,option):
raise raise
@ -92,7 +97,7 @@ class ConfigParser:
values = '\n '.join(values) values = '\n '.join(values)
else: else:
fp.write(' ') fp.write(' ')
fp.write(values) fp.write(values)
fp.write('\n') fp.write('\n')
fp.write('\n') fp.write('\n')