aboutsummaryrefslogtreecommitdiff
path: root/lib/python
diff options
context:
space:
mode:
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>2007-11-15 12:16:25 +0000
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>2007-11-15 12:16:25 +0000
commit89171895f878c5275f8d8e8a8f1e27de48cbf24c (patch)
treea36b22305d576cc2c39be66c92d14d0070f6fb69 /lib/python
parent2dc887734256563f9d6880a5f829294e5f44d04a (diff)
downloadenigma2-89171895f878c5275f8d8e8a8f1e27de48cbf24c.tar.gz
enigma2-89171895f878c5275f8d8e8a8f1e27de48cbf24c.zip
add converter to test config entrie values
Diffstat (limited to 'lib/python')
-rw-r--r--lib/python/Components/Converter/ConfigEntryTest.py51
-rw-r--r--lib/python/Components/Converter/Makefile.am3
2 files changed, 53 insertions, 1 deletions
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
+