confighelper: Add helper methods

Add "get_name()" and "get_prefix_section" methods

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Arksine 2020-11-14 06:15:42 -05:00
parent 0a7b580799
commit 1975b875a5
1 changed files with 6 additions and 0 deletions

View File

@ -31,6 +31,12 @@ class ConfigHelper:
def __contains__(self, key):
return key in self.config
def get_name(self):
return self.section
def get_prefix_sections(self, prefix):
return [s for s in self.sections() if s.startswith(prefix)]
def getsection(self, section):
if section not in self.config:
raise ConfigError(f"No section [{section}] in config")