finally fix satfinder with new config
[enigma2.git] / lib / python / Components / config.py
index b5a0bbbdba8049a1a93c7e9996827f95b6fb2b44..10f112c6379296d715a63ae2c30e198f4f8ea9b3 100644 (file)
@@ -1,6 +1,7 @@
 import time
 from Tools.NumericalTextInput import NumericalTextInput
 from Tools.Directories import resolveFilename, SCOPE_CONFIG
+import copy
 
 
 # ConfigElement, the base class of all ConfigElements.
@@ -124,7 +125,10 @@ class ConfigSelection(ConfigElement):
                else:
                        assert False, "ConfigSelection choices must be dict or list!"
                
-               assert len(self.choices), "you can't have an empty configselection"
+               #assert len(self.choices), "you can't have an empty configselection"
+               if len(self.choices) == 0:
+                       self.choices = [""]
+                       self.description[""] = ""
 
                if default is None:
                        default = self.choices[0]
@@ -164,9 +168,6 @@ class ConfigSelection(ConfigElement):
                        self.value = self.choices[(i + nchoices - 1) % nchoices]
                elif key == KEY_RIGHT:
                        self.value = self.choices[(i + 1) % nchoices]
-               elif key == KEY_TIMEOUT:
-                       self.timeout()
-                       return
 
        def getMulti(self, selected):
                return ("text", self.description[self.value])
@@ -280,7 +281,8 @@ class ConfigSequence(ConfigElement):
                self.limits = limits
                self.censor_char = censor_char
                
-               self.value = self.default = default
+               self.default = default
+               self.value = copy.copy(default)
 
        def validate(self):
                max_pos = 0
@@ -321,7 +323,6 @@ class ConfigSequence(ConfigElement):
                        self.validatePos()
                
                if key in KEY_NUMBERS:
-                       print "is number"
                        block_len = []
                        for x in self.limits:
                                block_len.append(len(str(x[1])))
@@ -357,8 +358,6 @@ class ConfigSequence(ConfigElement):
                        self.validate()
                        self.changed()
                        
-                       print "res:", self._value
-
        def getMulti(self, selected):
                value = ""
                mPos = self.marked_pos
@@ -504,8 +503,6 @@ class ConfigText(ConfigElement, NumericalTextInput):
                return ("mtext"[1-selected:], self.value, [self.marked_pos])
 
        def helpWindow(self):
-               print "helpWindow for text!"
-
                from Screens.NumericalTextInputHelpDialog import NumericalTextInputHelpDialog
                return (NumericalTextInputHelpDialog,self)
 
@@ -554,11 +551,11 @@ class ConfigSatlist(ConfigSelection):
        def __init__(self, list, default = None):
                if default is not None:
                        default = str(default)
-               if list == [ ]:
-                       list = [0, "N/A"]
                ConfigSelection.__init__(self, choices = [(str(orbpos), desc) for (orbpos, desc) in list], default = default)
 
        def getOrbitalPosition(self):
+               if self.value == "":
+                       return None
                return int(self.value)
        
        orbital_position = property(getOrbitalPosition)