From 65fef83e5668a23cce8693afb262c558969c4f82 Mon Sep 17 00:00:00 2001 From: Cyril Jaquier Date: Thu, 7 Jul 2005 16:51:52 +0000 Subject: [PATCH] - Made configreader more generic. Also used for global options now git-svn-id: https://fail2ban.svn.sourceforge.net/svnroot/fail2ban/branches/FAIL2BAN-0_5@118 a942ae1a-1317-0410-a47c-b1dcaea8d605 --- confreader/configreader.py | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/confreader/configreader.py b/confreader/configreader.py index 9c64a0aa..a1227055 100644 --- a/confreader/configreader.py +++ b/confreader/configreader.py @@ -36,19 +36,7 @@ class ConfigReader: The DEFAULT section contains the global information about Fail2Ban. Each other section is for a different log file. """ - - # Each optionValues entry is composed of an array with: - # 0 -> the type of the option - # 1 -> the name of the option - # 2 -> the default value for the option - optionValues = (["bool", "enabled", True], - ["str", "logfile", "/dev/null"], - ["str", "timeregex", ""], - ["str", "timepattern", ""], - ["str", "failregex", ""], - ["str", "fwbanrule", ""], - ["str", "fwunbanrule", ""]) - + def __init__(self, confPath): self.confPath = confPath self.configParser = SafeConfigParser() @@ -63,13 +51,17 @@ class ConfigReader: file except the DEFAULT section. """ return self.configParser.sections() - - def getLogOptions(self, sec): + + # Each optionValues entry is composed of an array with: + # 0 -> the type of the option + # 1 -> the name of the option + # 2 -> the default value for the option + def getLogOptions(self, sec, options): """ Gets all the options of a given section. The options are defined in the optionValues list. """ values = dict() - for option in self.optionValues: + for option in options: try: if option[0] == "bool": v = self.configParser.getboolean(sec, option[1])