From 89171895f878c5275f8d8e8a8f1e27de48cbf24c Mon Sep 17 00:00:00 2001 From: Andreas Monzner Date: Thu, 15 Nov 2007 12:16:25 +0000 Subject: [PATCH 1/1] add converter to test config entrie values --- .../Components/Converter/ConfigEntryTest.py | 51 +++++++++++++++++++ lib/python/Components/Converter/Makefile.am | 3 +- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 lib/python/Components/Converter/ConfigEntryTest.py diff --git a/lib/python/Components/Converter/ConfigEntryTest.py b/lib/python/Components/Converter/ConfigEntryTest.py new file mode 100644 index 00000000..166e6bea --- /dev/null +++ b/lib/python/Components/Converter/ConfigEntryTest.py @@ -0,0 +1,51 @@ +from Converter import Converter +from Components.Element import cached + +from Components.config import configfile + +class ConfigEntryTest(Converter, object): + def __init__(self, argstr): + Converter.__init__(self, argstr) + args = argstr.split(',') + self.argerror = False + self.checkSourceBoolean = False + self.invert = False + self.configKey = None + self.configValue = None + if len(args) < 2: + self.argerror = True + else: + if args[0].find("config.") != -1: + self.configKey = args[0] + self.configValue = args[1] + if len(args) > 2: + if args[2] == 'Invert': + self.invert = True + elif args[2] == 'CheckSourceBoolean': + self.checkSourceBoolean = True + else: + self.argerror = True + if len(args) > 3: + if args[3] == 'Invert': + self.invert = True + elif args[3] == 'CheckSourceBoolean': + self.checkSourceBoolean = True + else: + self.argerror = True + else: + self.argerror = True + if self.argerror: + print "ConfigEntryTest Converter got incorrect arguments", args, "!!!\narg[0] must start with 'config.',\narg[1] is the compare string,\narg[2],arg[3] are optional arguments and must be 'Invert' or 'CheckSourceBoolean'" + + @cached + def getBoolean(self): + if self.argerror: + print "ConfigEntryTest got invalid arguments", self.converter_arguments, "force True!!" + return True + if self.checkSourceBoolean and not self.source.boolean: + return False + val = configfile.getResolvedKey(self.configKey) + ret = val == self.configValue + return ret ^ self.invert + + boolean = property(getBoolean) diff --git a/lib/python/Components/Converter/Makefile.am b/lib/python/Components/Converter/Makefile.am index 73b689b3..f5188090 100644 --- a/lib/python/Components/Converter/Makefile.am +++ b/lib/python/Components/Converter/Makefile.am @@ -5,4 +5,5 @@ install_PYTHON = \ Poll.py RemainingToText.py StringList.py ServiceName.py FrontendInfo.py ServiceInfo.py \ ConditionalShowHide.py ServicePosition.py ValueRange.py RdsInfo.py Streaming.py \ StaticMultiList.py ServiceTime.py MovieInfo.py MenuEntryCompare.py StringListSelection.py \ - ValueBitTest.py TunerInfo.py + ValueBitTest.py TunerInfo.py ConfigEntryTest.py + -- 2.30.2