small optimizations and cleanups by Moritz Venn
authorghost <andreas.monzner@multimedia-labs.de>
Tue, 24 Feb 2009 19:56:21 +0000 (20:56 +0100)
committerghost <andreas.monzner@multimedia-labs.de>
Tue, 24 Feb 2009 19:56:21 +0000 (20:56 +0100)
84 files changed:
RecordTimer.py
keymapparser.py
lib/python/Components/Converter/FrontendInfo.py
lib/python/Components/Converter/RdsInfo.py
lib/python/Components/Converter/ServiceInfo.py
lib/python/Components/Converter/ServiceName.py
lib/python/Components/Converter/ServicePosition.py
lib/python/Components/Converter/ServiceTime.py
lib/python/Components/Converter/Streaming.py
lib/python/Components/DreamInfoHandler.py
lib/python/Components/Element.py
lib/python/Components/Harddisk.py
lib/python/Components/HelpMenuList.py
lib/python/Components/Language.py
lib/python/Components/NimManager.py
lib/python/Components/ParentalControl.py
lib/python/Components/ParentalControlList.py
lib/python/Components/PluginComponent.py
lib/python/Components/PluginList.py
lib/python/Components/Renderer/FrontpanelLed.py
lib/python/Components/Renderer/Picon.py
lib/python/Components/Scanner.py
lib/python/Components/SelectionList.py
lib/python/Components/Sources/RdsDecoder.py
lib/python/Components/TimerList.py
lib/python/Components/TimerSanityCheck.py
lib/python/Components/Timezones.py
lib/python/Components/config.py
lib/python/Plugins/Extensions/CutListEditor/plugin.py
lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py
lib/python/Plugins/Extensions/DVDBurn/plugin.py
lib/python/Plugins/Extensions/DVDPlayer/plugin.py
lib/python/Plugins/Extensions/FileManager/plugin.py
lib/python/Plugins/Extensions/MediaPlayer/plugin.py
lib/python/Plugins/Extensions/MediaScanner/plugin.py
lib/python/Plugins/Extensions/PicturePlayer/plugin.py
lib/python/Plugins/Extensions/SocketMMI/plugin.py
lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py
lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py
lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py
lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py
lib/python/Plugins/SystemPlugins/Videomode/plugin.py
lib/python/Screens/About.py
lib/python/Screens/ChannelSelection.py
lib/python/Screens/Ci.py
lib/python/Screens/Console.py
lib/python/Screens/DefaultWizard.py
lib/python/Screens/EpgSelection.py
lib/python/Screens/EventView.py
lib/python/Screens/HarddiskSetup.py
lib/python/Screens/HelpMenu.py
lib/python/Screens/InfoBar.py
lib/python/Screens/InfoBarGenerics.py
lib/python/Screens/LanguageSelection.py
lib/python/Screens/LocationBox.py
lib/python/Screens/Menu.py
lib/python/Screens/MessageBox.py
lib/python/Screens/MovieSelection.py
lib/python/Screens/Mute.py
lib/python/Screens/NetworkSetup.py
lib/python/Screens/NumericalTextInputHelpDialog.py
lib/python/Screens/PVRState.py
lib/python/Screens/ParentalControlSetup.py
lib/python/Screens/PluginBrowser.py
lib/python/Screens/Rc.py
lib/python/Screens/Satconfig.py
lib/python/Screens/ServiceInfo.py
lib/python/Screens/Setup.py
lib/python/Screens/Standby.py
lib/python/Screens/SubservicesQuickzap.py
lib/python/Screens/SubtitleDisplay.py
lib/python/Screens/Subtitles.py
lib/python/Screens/TaskView.py
lib/python/Screens/TimeDateInput.py
lib/python/Screens/TimerEdit.py
lib/python/Screens/TimerEntry.py
lib/python/Screens/TimerSelection.py
lib/python/Screens/VirtualKeyBoard.py
lib/python/Screens/Wizard.py
lib/python/Screens/WizardLanguage.py
lib/python/Tools/NumericalTextInput.py
mytest.py
skin.py
timer.py

index aeff9d0..9f3b2ff 100644 (file)
@@ -63,7 +63,7 @@ class RecordTimerEntry(timer.TimerEntry, object):
                if event == iRecordableService.evEnd:
                        print "RecordTimer.staticGotRecordEvent(iRecordableService.evEnd)"
                        recordings = NavigationInstance.instance.getRecordings()
-                       if not len(recordings): # no more recordings exist
+                       if not recordings: # no more recordings exist
                                rec_time = NavigationInstance.instance.RecordTimer.getNextRecordingTime()
                                if rec_time > 0 and (rec_time - time.time()) < 360:
                                        print "another recording starts in", rec_time - time.time(), "seconds... do not shutdown yet"
index 63bca0f..0e544e9 100644 (file)
@@ -8,10 +8,10 @@ from Tools.KeyBindings import addKeyBinding
 
 class KeymapError(Exception):
     def __init__(self, message):
-        self.message = message
+        self.msg = message
 
     def __str__(self):
-        return self.message
+        return self.msg
 
 def parseKeys(context, filename, actionmap, device, keys):
        for x in keys.findall("key"):
index 796ac33..4043a1b 100644 (file)
@@ -29,7 +29,7 @@ class FrontendInfo(Converter, object):
 
        @cached
        def getText(self):
-               assert self.type not in [self.LOCK, self.SLOT_NUMBER], "the text output of FrontendInfo cannot be used for lock info"
+               assert self.type not in (self.LOCK, self.SLOT_NUMBER), "the text output of FrontendInfo cannot be used for lock info"
                percent = None
                if self.type == self.BER: # as count
                        count = self.source.ber
@@ -54,7 +54,7 @@ class FrontendInfo(Converter, object):
 
        @cached
        def getBool(self):
-               assert self.type in [self.LOCK, self.BER], "the boolean output of FrontendInfo can only be used for lock or BER info"
+               assert self.type in (self.LOCK, self.BER), "the boolean output of FrontendInfo can only be used for lock or BER info"
                if self.type == self.LOCK:
                        lock = self.source.lock
                        if lock is None:
index 3a7b2be..f3f2b67 100644 (file)
@@ -9,18 +9,12 @@ class RdsInfo(Converter, object):
 
        def __init__(self, type):
                Converter.__init__(self, type)
-               self.type = {
-                               "RadioText": self.RADIO_TEXT_CHANGED,
-                               "RtpText": self.RTP_TEXT_CHANGED,
-                               "RasInteractiveAvailable": self.RASS_INTERACTIVE_AVAILABLE
+               self.type, self.interesting_events = {
+                               "RadioText": (self.RADIO_TEXT_CHANGED, (iPlayableService.evUpdatedRadioText,)),
+                               "RtpText": (self.RTP_TEXT_CHANGED, (iPlayableService.evUpdatedRtpText,)),
+                               "RasInteractiveAvailable": (self.RASS_INTERACTIVE_AVAILABLE, (iPlayableService.evUpdatedRassInteractivePicMask,))
                        }[type]
 
-               self.interesting_events = {
-                               self.RADIO_TEXT_CHANGED: [iPlayableService.evUpdatedRadioText],
-                               self.RTP_TEXT_CHANGED: [iPlayableService.evUpdatedRtpText],
-                               self.RASS_INTERACTIVE_AVAILABLE: [iPlayableService.evUpdatedRassInteractivePicMask]
-                       }[self.type]
-
        @cached
        def getText(self):
                decoder = self.source.decoder
index 7118025..d4054f0 100644 (file)
@@ -13,26 +13,16 @@ class ServiceInfo(Converter, object):
 
        def __init__(self, type):
                Converter.__init__(self, type)
-               self.type = {
-                               "HasTelext": self.HAS_TELETEXT,
-                               "IsMultichannel": self.IS_MULTICHANNEL,
-                               "IsCrypted": self.IS_CRYPTED,
-                               "IsWidescreen": self.IS_WIDESCREEN,
-                               "SubservicesAvailable": self.SUBSERVICES_AVAILABLE,
-                               "VideoWidth": self.XRES,
-                               "VideoHeight": self.YRES,
+               self.type, self.interesting_events = {
+                               "HasTelext": (self.HAS_TELETEXT, (iPlayableService.evUpdatedInfo,)),
+                               "IsMultichannel": (self.IS_MULTICHANNEL, (iPlayableService.evUpdatedInfo,)),
+                               "IsCrypted": (self.IS_CRYPTED, (iPlayableService.evUpdatedInfo,)),
+                               "IsWidescreen": (self.IS_WIDESCREEN, (iPlayableService.evVideoSizeChanged,)),
+                               "SubservicesAvailable": (self.SUBSERVICES_AVAILABLE, (iPlayableService.evUpdatedEventInfo,)),
+                               "VideoWidth": (self.XRES, (iPlayableService.evVideoSizeChanged,)),
+                               "VideoHeight": (self.YRES, (iPlayableService.evVideoSizeChanged,)),
                        }[type]
 
-               self.interesting_events = {
-                               self.HAS_TELETEXT: [iPlayableService.evUpdatedInfo],
-                               self.IS_MULTICHANNEL: [iPlayableService.evUpdatedInfo],
-                               self.IS_CRYPTED: [iPlayableService.evUpdatedInfo],
-                               self.IS_WIDESCREEN: [iPlayableService.evVideoSizeChanged],
-                               self.SUBSERVICES_AVAILABLE: [iPlayableService.evUpdatedEventInfo],
-                               self.XRES: [iPlayableService.evVideoSizeChanged],
-                               self.YRES: [iPlayableService.evVideoSizeChanged],
-                       }[self.type]
-
        def getServiceInfoString(self, info, what):
                v = info.getInfo(what)
                if v == -1:
@@ -56,16 +46,18 @@ class ServiceInfo(Converter, object):
                        audio = service.audioTracks()
                        if audio:
                                n = audio.getNumberOfTracks()
-                               for x in range(n):
-                                       i = audio.getTrackInfo(x)
+                               idx = 0
+                               while idx < n:
+                                       i = audio.getTrackInfo(idx)
                                        description = i.getDescription();
-                                       if description.find("AC3") != -1 or description.find("DTS") != -1:
+                                       if "AC3" in description or "DTS" in description:
                                                return True
+                                       idx += 1
                        return False
                elif self.type == self.IS_CRYPTED:
                        return info.getInfo(iServiceInformation.sIsCrypted) == 1
                elif self.type == self.IS_WIDESCREEN:
-                       return info.getInfo(iServiceInformation.sAspect) in [3, 4, 7, 8, 0xB, 0xC, 0xF, 0x10]
+                       return info.getInfo(iServiceInformation.sAspect) in (3, 4, 7, 8, 0xB, 0xC, 0xF, 0x10)
                elif self.type == self.SUBSERVICES_AVAILABLE:
                        subservices = service.subServices()
                        return subservices and subservices.getNumberOfSubservices() > 0
index 18b1f2a..210c1aa 100644 (file)
@@ -47,5 +47,5 @@ class ServiceName(Converter, object):
        text = property(getText)
 
        def changed(self, what):
-               if what[0] != self.CHANGED_SPECIFIC or what[1] in [iPlayableService.evStart]:
+               if what[0] != self.CHANGED_SPECIFIC or what[1] in (iPlayableService.evStart,):
                        Converter.changed(self, what)
index 2bcc549..b92af40 100644 (file)
@@ -35,7 +35,7 @@ class ServicePosition(Converter, Poll, object):
                elif type == "Gauge":
                        self.type = self.TYPE_GAUGE
                else:
-                       raise ElementError("type must be {Length|Position|Remaining|Gauge} with optional arguments {Negate|Detailed|ShowHours|NoSeconds}")
+                       raise ElementError("type must be {Length|Position|Remaining|Gauge} with optional arguments {Negate|Detailed|ShowHours|ShowNoSeconds} for ServicePosition converter")
 
                self.poll_enabled = self.type != self.TYPE_LENGTH
 
@@ -128,8 +128,8 @@ class ServicePosition(Converter, Poll, object):
        value = property(getValue)
 
        def changed(self, what):
-               cutlist_refresh = what[0] != self.CHANGED_SPECIFIC or what[1] in [iPlayableService.evCuesheetChanged]
-               time_refresh = what[0] == self.CHANGED_POLL or what[0] == self.CHANGED_SPECIFIC and what[1] in [iPlayableService.evCuesheetChanged]
+               cutlist_refresh = what[0] != self.CHANGED_SPECIFIC or what[1] in (iPlayableService.evCuesheetChanged,)
+               time_refresh = what[0] == self.CHANGED_POLL or what[0] == self.CHANGED_SPECIFIC and what[1] in (iPlayableService.evCuesheetChanged,)
 
                if cutlist_refresh:
                        if self.type == self.TYPE_GAUGE:
index 8996506..d30839c 100644 (file)
@@ -16,7 +16,7 @@ class ServiceTime(Converter, object):
                elif type == "Duration":
                        self.type = self.DURATION
                else:
-                       raise ElementError("'%s' is not <StartTime|EndTime|Duration> for eEventTime converter" % type)
+                       raise ElementError("'%s' is not <StartTime|EndTime|Duration> for ServiceTime converter" % type)
 
        @cached
        def getTime(self):
index 2746ee8..0c0d274 100644 (file)
@@ -9,9 +9,6 @@ from Components.Element import cached
 #      "+d:[p:t[,p:t...]]" with d=demux nr, p: pid, t: type
 
 class Streaming(Converter):
-       def __init__(self, type):
-               Converter.__init__(self, type)
-
        @cached
        def getText(self):
                service = self.source.service
index c5f8262..2f2e757 100644 (file)
@@ -31,7 +31,7 @@ class InfoHandler(xml.sax.ContentHandler):
        def startElement(self, name, attrs):
                #print name, ":", attrs.items()
                self.elements.append(name)
-               if name in ["hardware", "bcastsystem", "satellite", "tag"]:
+               if name in ("hardware", "bcastsystem", "satellite", "tag"):
                        if not attrs.has_key("type"):
                                        self.printError(str(name) + " tag with no type attribute")
                        if self.elements[-3] == "default":
index f4a8f12..509a1c8 100644 (file)
@@ -18,10 +18,10 @@ def cached(f):
 
 class ElementError(Exception):
     def __init__(self, message):
-        self.message = message
+        self.msg = message
 
     def __str__(self):
-        return self.message
+        return self.msg
 
 class Element(object):
        CHANGED_DEFAULT = 0   # initial "pull" state
index 75d68fa..8664f79 100755 (executable)
@@ -44,8 +44,8 @@ class Harddisk:
                        self.timer.callback.remove(self.runIdle)
 
        def bus(self):
-               ide_cf = self.device.find("hd") == 0 and self.devidex2.find("host0") == -1 # 7025 specific
-               internal = self.device.find("hd") == 0
+               ide_cf = self.device[:2] == "hd" and "host0" not in self.devidex2 # 7025 specific
+               internal = self.device[:2] == "hd"
                if ide_cf:
                        ret = "External (CF)"
                elif internal:
@@ -73,14 +73,14 @@ class Harddisk:
                return "%d.%03d GB" % (cap/1024, cap%1024)
 
        def model(self):
-               if self.device.find("hd") == 0:
+               if self.device[:2] == "hd":
                        procfile = tryOpen("/proc/ide/"+self.device+"/model")
                        if procfile == "":
                                return ""
                        line = procfile.readline()
                        procfile.close()
                        return line.strip()
-               elif self.device.find("sd") == 0:
+               elif self.device[:2] == "sd":
                        procfile = tryOpen("/sys/block/"+self.device+"/device/vendor")
                        if procfile == "":
                                return ""
@@ -358,8 +358,7 @@ class HarddiskManager:
                                        ("/", _("Internal Flash"))
                                ]
                
-               for x in p:
-                       self.partitions.append(Partition(mountpoint = x[0], description = x[1]))
+               self.partitions.extend([ Partition(mountpoint = x[0], description = x[1]) for x in p ])
 
        def getBlockDevInfo(self, blockdev):
                devpath = "/sys/block/" + blockdev
@@ -371,14 +370,14 @@ class HarddiskManager:
                try:
                        removable = bool(int(open(devpath + "/removable").read()))
                        dev = int(open(devpath + "/dev").read().split(':')[0])
-                       if dev in [7, 31]: # loop, mtdblock
+                       if dev in (7, 31): # loop, mtdblock
                                blacklisted = True
                        if blockdev[0:2] == 'sr':
                                is_cdrom = True
                        if blockdev[0:2] == 'hd':
                                try:
                                        media = open("/proc/ide/%s/media" % blockdev).read()
-                                       if media.find("cdrom") != -1:
+                                       if "cdrom" in media:
                                                is_cdrom = True
                                except IOError:
                                        error = True
index ddf871a..66139df 100755 (executable)
@@ -17,8 +17,6 @@ class HelpMenuList(GUIComponent):
                l = [ ]
                for (actionmap, context, actions) in helplist:
                        for (action, help) in actions:
-                               entry = [ ]
-
                                buttons = queryKeyBinding(context, action)
 
                                # do not display entries which are not accessible from keys
@@ -36,13 +34,15 @@ class HelpMenuList(GUIComponent):
                                if flags & 8: # for long keypresses, prepend l_ into the key name.
                                        name = (name[0], "long")
                                        
-                               entry.append( (actionmap, context, action, name ) )
-                                       
+                               entry = [ (actionmap, context, action, name ) ]
+
                                if isinstance(help, list):
                                        self.extendedHelp = True
                                        print "extendedHelpEntry found"
-                                       entry.append( (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 400, 26, 0, 0, help[0]) )
-                                       entry.append( (eListboxPythonMultiContent.TYPE_TEXT, 0, 28, 400, 20, 1, 0, help[1]) )
+                                       entry.extend((
+                                               (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 400, 26, 0, 0, help[0]),
+                                               (eListboxPythonMultiContent.TYPE_TEXT, 0, 28, 400, 20, 1, 0, help[1])
+                                       ))
                                else:
                                        entry.append( (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 400, 28, 0, 0, help) )
                                        
index 74dd67d..268fdb2 100644 (file)
@@ -64,18 +64,17 @@ class Language:
                        self.activateLanguage(self.langlist[index])
 
        def getLanguageList(self):
-               list = []
-               for x in self.langlist:
-                       list.append((x, self.lang[x]))
-               return list
+               return [ (x, self.lang[x]) for x in self.langlist ]
 
        def getActiveLanguage(self):
                return self.activeLanguage
        
        def getActiveLanguageIndex(self):
-               for count in range(len(self.langlist)):
-                       if self.langlist[count] == self.activeLanguage:
-                               return count
+               idx = 0
+               for x in self.langlist:
+                       if x == self.activeLanguage:
+                               return idx
+                       idx += 1
                return None                     
 
        def getLanguage(self):
index 75ad377..4877857 100644 (file)
@@ -112,7 +112,7 @@ class SecConfigure:
                
        def getRoot(self, slotid, connto):
                visited = []
-               while (self.NimManager.getNimConfig(connto).configMode.value in ["satposdepends", "equal", "loopthrough"]):
+               while (self.NimManager.getNimConfig(connto).configMode.value in ("satposdepends", "equal", "loopthrough")):
                        connto = int(self.NimManager.getNimConfig(connto).connectedTo.value)
                        if connto in visited: # prevent endless loop
                                return slotid
@@ -168,7 +168,7 @@ class SecConfigure:
                        hw = HardwareInfo()
                        if slot.isCompatible("DVB-S"):
                                print "slot: " + str(x) + " configmode: " + str(nim.configMode.value)
-                               if nim.configMode.value in [ "loopthrough", "satposdepends", "nothing" ]:
+                               if nim.configMode.value in ( "loopthrough", "satposdepends", "nothing" ):
                                        pass
                                else:
                                        sec.setSlotNotLinked(x)
@@ -447,7 +447,7 @@ class NIM(object):
        def __init__(self, slot, type, description, has_outputs = True, internally_connectable = None):
                self.slot = slot
 
-               if type not in ["DVB-S", "DVB-C", "DVB-T", "DVB-S2", None]:
+               if type not in ("DVB-S", "DVB-C", "DVB-T", "DVB-S2", None):
                        print "warning: unknown NIM type %s, not using." % type
                        type = None
 
@@ -458,20 +458,20 @@ class NIM(object):
 
        def isCompatible(self, what):
                compatible = {
-                               None: [None],
-                               "DVB-S": ["DVB-S", None],
-                               "DVB-C": ["DVB-C", None],
-                               "DVB-T": ["DVB-T", None],
-                               "DVB-S2": ["DVB-S", "DVB-S2", None]
+                               None: (None,),
+                               "DVB-S": ("DVB-S", None),
+                               "DVB-C": ("DVB-C", None),
+                               "DVB-T": ("DVB-T", None),
+                               "DVB-S2": ("DVB-S", "DVB-S2", None)
                        }
                return what in compatible[self.type]
        
        def connectableTo(self):
                connectable = {
-                               "DVB-S": ["DVB-S", "DVB-S2"],
-                               "DVB-C": ["DVB-C"],
-                               "DVB-T": ["DVB-T"],
-                               "DVB-S2": ["DVB-S", "DVB-S2"]
+                               "DVB-S": ("DVB-S", "DVB-S2"),
+                               "DVB-C": ("DVB-C",),
+                               "DVB-T": ("DVB-T",),
+                               "DVB-S2": ("DVB-S", "DVB-S2")
                        }
                return connectable[self.type]
 
@@ -781,10 +781,10 @@ class NimManager:
 
                        if configMode == "simple":
                                dm = nim.diseqcMode.value
-                               if dm in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
+                               if dm in ("single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
                                        if nim.diseqcA.orbital_position != 3601:
                                                list.append(self.satList[nim.diseqcA.index-1])
-                               if dm in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
+                               if dm in ("toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
                                        if nim.diseqcB.orbital_position != 3601:
                                                list.append(self.satList[nim.diseqcB.index-1])
                                if dm == "diseqc_a_b_c_d":
index 8c8a330..d68e01f 100644 (file)
@@ -33,7 +33,7 @@ def InitParentalControl():
 
        config.ParentalControl.servicepin = ConfigSubList()
 
-       for i in range(3):
+       for i in (0, 1, 2):
                config.ParentalControl.servicepin.append(ConfigPIN(default = -1))
                #config.ParentalControl.servicepin.append(configElement("config.ParentalControl.servicepin.level" + str(i), configSequence, "0000", configSequenceArg().get("PINCODE", (4, ""))))
 
@@ -117,10 +117,7 @@ class ParentalControl:
                        return -1
        
        def getPinList(self):
-               pinList = []
-               for x in config.ParentalControl.servicepin:
-                       pinList.append(x.value)
-               return pinList
+               return [ x.value for x in config.ParentalControl.servicepin ]
        
        def servicePinEntered(self, service, result):
 #              levelNeeded = 0
index 7191262..128e6d3 100644 (file)
@@ -8,8 +8,10 @@ from Tools.LoadPixmap import LoadPixmap
 lockPicture = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/lock.png"))
 
 def ParentalControlEntryComponent(service, name, locked = True):
-       res = [ (service, name, locked) ]
-       res.append((eListboxPythonMultiContent.TYPE_TEXT, 80, 5, 300, 50, 0, RT_HALIGN_LEFT, name))
+       res = [
+               (service, name, locked),
+               (eListboxPythonMultiContent.TYPE_TEXT, 80, 5, 300, 50, 0, RT_HALIGN_LEFT, name)
+       ]
        if locked:
                res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 0, 32, 32, lockPicture))
        return res
index 6e357cd..fff5c47 100644 (file)
@@ -96,9 +96,9 @@ class PluginComponent:
                res = [ ]
 
                for x in where:
-                       for p in self.plugins.get(x, [ ]):
-                               res.append(p)
-               return res
+                       res.extend(self.plugins.get(x, [ ]))
+
+               return  res
 
        def getPluginsForMenu(self, menuid):
                res = [ ]
index 63136cc..39c60ff 100644 (file)
@@ -7,40 +7,38 @@ from enigma import eListboxPythonMultiContent, gFont
 from Tools.LoadPixmap import LoadPixmap
 
 def PluginEntryComponent(plugin):
-       res = [ plugin ]
-       
-       res.append(MultiContentEntryText(pos=(120, 5), size=(320, 25), font=0, text=plugin.name))
-       res.append(MultiContentEntryText(pos=(120, 26), size=(320, 17), font=1, text=plugin.description))
-
        if plugin.icon is None:
                png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/plugin.png"))
        else:
                png = plugin.icon
-       res.append(MultiContentEntryPixmapAlphaTest(pos=(10, 5), size=(100, 40), png = png))
-       
-       return res
+
+       return [
+               plugin,
+               MultiContentEntryText(pos=(120, 5), size=(320, 25), font=0, text=plugin.name),
+               MultiContentEntryText(pos=(120, 26), size=(320, 17), font=1, text=plugin.description),
+               MultiContentEntryPixmapAlphaTest(pos=(10, 5), size=(100, 40), png = png)
+       ]
 
 def PluginCategoryComponent(name, png):
-       res = [ name ]
-       
-       res.append(MultiContentEntryText(pos=(120, 5), size=(320, 25), font=0, text=name))
-       res.append(MultiContentEntryPixmapAlphaTest(pos=(10, 0), size=(100, 50), png = png))
-       
-       return res
+       return [
+               name,
+               MultiContentEntryText(pos=(120, 5), size=(320, 25), font=0, text=name),
+               MultiContentEntryPixmapAlphaTest(pos=(10, 0), size=(100, 50), png = png)
+       ]
 
 def PluginDownloadComponent(plugin, name):
-       res = [ plugin ]
-       
-       res.append(MultiContentEntryText(pos=(120, 5), size=(320, 25), font=0, text=name))
-       res.append(MultiContentEntryText(pos=(120, 26), size=(320, 17), font=1, text=plugin.description))
-
        if plugin.icon is None:
                png = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/plugin.png"))
        else:
                png = plugin.icon
-       res.append(MultiContentEntryPixmapAlphaTest(pos=(10, 0), size=(100, 50), png = png))
+
+       return [
+               plugin,
+               MultiContentEntryText(pos=(120, 5), size=(320, 25), font=0, text=name),
+               MultiContentEntryText(pos=(120, 26), size=(320, 17), font=1, text=plugin.description),
+               MultiContentEntryPixmapAlphaTest(pos=(10, 0), size=(100, 50), png = png)
+       ]
        
-       return res
 
 class PluginList(MenuList):
        def __init__(self, list, enableWrapAround=False):
index 7bb584e..c008396 100644 (file)
@@ -2,9 +2,6 @@ from Components.Element import Element
 
 # this is not a GUI renderer.
 class FrontpanelLed(Element):
-       def __init__(self):
-               Element.__init__(self)
-
        def changed(self, *args, **kwargs):
                if self.source.value:
                        pattern = 0x55555555
index de19c9a..5ae43ed 100644 (file)
@@ -6,9 +6,9 @@ from enigma import ePixmap
 from Tools.Directories import fileExists, SCOPE_SKIN_IMAGE, SCOPE_CURRENT_SKIN, resolveFilename
 
 class Picon(Renderer):
-       searchPaths = ['/usr/share/enigma2/%s/',
+       searchPaths = ('/usr/share/enigma2/%s/',
                                '/media/cf/%s/',
-                               '/media/usb/%s/']
+                               '/media/usb/%s/')
 
        def __init__(self):
                Renderer.__init__(self)
index 17c4aaa..813c09f 100644 (file)
@@ -114,13 +114,10 @@ def scanDevice(mountpoint):
 
        # ...then remove with_subdir=False when same path exists
        # with with_subdirs=True
-       for p in set(paths_to_scan):
+       for p in paths_to_scan:
                if p.with_subdirs == True and ScanPath(path=p.path) in paths_to_scan:
                        paths_to_scan.remove(ScanPath(path=p.path))
 
-       # convert to list
-       paths_to_scan = list(paths_to_scan)
-
        from Components.Harddisk import harddiskmanager 
        blockdev = mountpoint.rstrip("/").rsplit('/',1)[-1]
        error, blacklisted, removable, is_cdrom, partitions, medium_found = harddiskmanager.getBlockDevInfo(blockdev)
index a4f1d71..08af7d0 100644 (file)
@@ -6,8 +6,10 @@ from Tools.LoadPixmap import LoadPixmap
 selectionpng = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/icons/selectioncross.png"))
 
 def SelectionEntryComponent(description, value, index, selected):
-       res = [ (description, value, index, selected) ]
-       res.append((eListboxPythonMultiContent.TYPE_TEXT, 30, 3, 500, 30, 0, RT_HALIGN_LEFT, description))
+       res = [
+               (description, value, index, selected),
+               (eListboxPythonMultiContent.TYPE_TEXT, 30, 3, 500, 30, 0, RT_HALIGN_LEFT, description)
+       ]
        if selected:
                res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 0, 0, 30, 30, selectionpng))
        return res
@@ -23,13 +25,11 @@ class SelectionList(MenuList):
                self.setList(self.list)
 
        def toggleSelection(self):
-               item = self.list[self.getSelectedIndex()][0]
-               self.list[self.getSelectedIndex()] = SelectionEntryComponent(item[0], item[1], item[2], not item[3])
+               idx = self.getSelectedIndex()
+               item = self.list[idx][0]
+               self.list[idx] = SelectionEntryComponent(item[0], item[1], item[2], not item[3])
                self.setList(self.list)
 
        def getSelectionsList(self):
-               list = []
-               for item in self.list:
-                       if item[0][3]:
-                               list.append((item[0][0], item[0][1], item[0][2]))
-               return list
+               return [ (item[0][0], item[0][1], item[0][2]) for item in self.list if item[0][3] ]
+
index 3ec9a25..26a3e5a 100644 (file)
@@ -23,7 +23,7 @@ class RdsDecoder(PerServiceBase, Source, object):
        decoder = property(getDecoder)
 
        def gotEvent(self, what):
-               if what in [iPlayableService.evStart, iPlayableService.evEnd]:
+               if what in (iPlayableService.evStart, iPlayableService.evEnd):
                        self.changed((self.CHANGED_CLEAR,))
                else:
                        self.changed((self.CHANGED_SPECIFIC, what))
index a237c36..1109860 100644 (file)
@@ -21,7 +21,7 @@ class TimerList(HTMLComponent, GUIComponent, object):
                res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 30, width, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, timer.name))
 
                repeatedtext = ""
-               days = [ _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun") ]
+               days = ( _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun") )
                if timer.repeated:
                        flags = timer.repeated
                        count = 0
index cf50502..c0ca10f 100644 (file)
@@ -135,8 +135,7 @@ class TimerSanityCheck:
                                                        self.nrep_eventlist.extend([(new_event_begin, self.bflag, event[1]),(new_event_end, self.eflag, event[1])])
                else:
                        offset_0 = 345600 # the Epoch begins on Thursday
-                       weeks = 2 # test two weeks to take care of Sunday-Monday transitions
-                       for cnt in range(weeks):
+                       for cnt in (0, 1): # test two weeks to take care of Sunday-Monday transitions
                                for event in self.rep_eventlist:
                                        if event[1] == -1: # -1 is the identifier of the changed timer
                                                event_begin = self.newtimer.begin
index f3e24ee..7f70915 100644 (file)
@@ -52,11 +52,8 @@ class Timezones:
                        e_tzset()
                
        def getTimezoneList(self):
-               list = []
-               for x in self.timezones:
-                       list.append(str(x[0]))
-               return list
-       
+               return [ str(x[0]) for x in self.timezones ]
+
        def getDefaultTimezone(self):
                # TODO return something more useful - depending on country-settings?
                t = "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Vienna"
index e3a29b5..79e99b0 100755 (executable)
@@ -385,7 +385,7 @@ class ConfigBoolean(ConfigElement):
                self.value = self.last_value = self.default = default
 
        def handleKey(self, key):
-               if key in [KEY_LEFT, KEY_RIGHT]:
+               if key in (KEY_LEFT, KEY_RIGHT):
                        self.value = not self.value
                elif key == KEY_HOME:
                        self.value = False
@@ -1187,7 +1187,7 @@ class ConfigSet(ConfigElement):
                                self.pos = -1
                        else:
                                self.pos += 1
-               elif key in [KEY_HOME, KEY_END]:
+               elif key in (KEY_HOME, KEY_END):
                        self.pos = -1
 
        def genString(self, lst):
@@ -1352,7 +1352,7 @@ class ConfigLocations(ConfigElement):
                        self.pos += 1
                        if self.pos >= len(self.value):
                                self.pos = -1
-               elif key in [KEY_HOME, KEY_END]:
+               elif key in (KEY_HOME, KEY_END):
                        self.pos = -1
 
        def getText(self):
index 1ef15a5..ed7cfb7 100644 (file)
@@ -317,7 +317,7 @@ class CutListEditor(Screen, InfoBarBase, InfoBarSeek, InfoBarCueSheetSupport, He
                elif result == CutListContextMenu.RET_ENDCUT:
                        # remove in/out marks between the new cut
                        for (where, what) in self.cut_list[:]:
-                               if self.cut_start <= where <= self.context_position and what in [0,1]:
+                               if self.cut_start <= where <= self.context_position and what in (0,1):
                                        self.cut_list.remove((where, what))
 
                        bisect.insort(self.cut_list, (self.cut_start, 1))
@@ -350,7 +350,7 @@ class CutListEditor(Screen, InfoBarBase, InfoBarSeek, InfoBarCueSheetSupport, He
                elif result == CutListContextMenu.RET_REMOVEBEFORE:
                        # remove in/out marks before current position
                        for (where, what) in self.cut_list[:]:
-                               if where <= self.context_position and what in [0,1]:
+                               if where <= self.context_position and what in (0,1):
                                        self.cut_list.remove((where, what))
                        # add 'in' point
                        bisect.insort(self.cut_list, (self.context_position, 0))
@@ -358,7 +358,7 @@ class CutListEditor(Screen, InfoBarBase, InfoBarSeek, InfoBarCueSheetSupport, He
                elif result == CutListContextMenu.RET_REMOVEAFTER:
                        # remove in/out marks after current position
                        for (where, what) in self.cut_list[:]:
-                               if where >= self.context_position and what in [0,1]:
+                               if where >= self.context_position and what in (0,1):
                                        self.cut_list.remove((where, what))
                        # add 'out' point
                        bisect.insort(self.cut_list, (self.context_position, 1))
index 40b85b7..1c2099f 100644 (file)
@@ -154,7 +154,7 @@ class LanguageChoices():
                        if len(key) == 2:
                                self.langdict[key] = val[0]
                for key, val in self.langdict.iteritems():
-                       if key not in [syslang, 'en']:
+                       if key not in (syslang, 'en'):
                                self.langdict[key] = val
                                self.choices.append((key, val))
                self.choices.sort()
@@ -164,8 +164,7 @@ class LanguageChoices():
 
        def getLanguage(self, DVB_lang):
                DVB_lang = DVB_lang.lower()
-               stripwords = ["stereo", "audio", "description", "2ch", "dolby digital"]
-               for word in stripwords:
+               for word in ("stereo", "audio", "description", "2ch", "dolby digital"):
                        DVB_lang = DVB_lang.replace(word,"").strip()
                for key, val in LanguageCodes.iteritems():
                        if DVB_lang.find(key.lower()) == 0:
@@ -183,4 +182,4 @@ class LanguageChoices():
                                return key
                return "nolang"
 
-languageChoices = LanguageChoices()
\ No newline at end of file
+languageChoices = LanguageChoices()
index 29076ce..45f438d 100644 (file)
@@ -12,5 +12,6 @@ def main_add(session, service, **kwargs):
        dvdburn.selectedSource(service)
 
 def Plugins(**kwargs):
-       return [PluginDescriptor(name="DVD Burn", description=_("Burn to DVD..."), where = PluginDescriptor.WHERE_MOVIELIST, fnc=main_add, icon="dvdburn.png"),
-               PluginDescriptor(name="DVD Burn", description=_("Burn to DVD..."), where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main, icon="dvdburn.png") ]
+       descr = _("Burn to DVD...")
+       return [PluginDescriptor(name="DVD Burn", description=descr, where = PluginDescriptor.WHERE_MOVIELIST, fnc=main_add, icon="dvdburn.png"),
+               PluginDescriptor(name="DVD Burn", description=descr, where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main, icon="dvdburn.png") ]
index 6a8ffc6..80629c5 100644 (file)
@@ -705,7 +705,7 @@ def filescan(**kwargs):
                                        ScanPath(path = "", with_subdirs = False),
                                ],
                        name = "DVD",
-                       description = "Play DVD",
+                       description = _("Play DVD"),
                        openfnc = filescan_open,
                )]              
 
index 1238981..62c9e7b 100644 (file)
@@ -59,5 +59,6 @@ def main(session, **kwargs):
        session.open(FileManager)
 
 def Plugins(**kwargs):
-       return [PluginDescriptor(name="File-Manager", description="Lets you view/edit files in your Dreambox", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main),
-                       PluginDescriptor(name="File-Manager", description="Lets you view/edit files in your Dreambox", where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=main)]
+       descr = _("Lets you view/edit files in your Dreambox")
+       return [PluginDescriptor(name="File-Manager", description=descr, where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main),
+                       PluginDescriptor(name="File-Manager", description=descr, where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=main)]
index e81750b..e26c65d 100644 (file)
@@ -991,7 +991,7 @@ def filescan(**kwargs):
                                        ScanPath(path = "", with_subdirs = False),
                                ],
                        name = "Movie",
-                       description = "View Movies...",
+                       description = _("View Movies..."),
                        openfnc = filescan_open,
                ),
                Scanner(mimetypes = ["video/x-vcd"],
@@ -1001,7 +1001,7 @@ def filescan(**kwargs):
                                        ScanPath(path = "MPEGAV", with_subdirs = False),
                                ],
                        name = "Video CD",
-                       description = "View Video CD...",
+                       description = _("View Video CD..."),
                        openfnc = filescan_open,
                ),
                Scanner(mimetypes = ["audio/mpeg", "audio/x-wav", "application/ogg", "audio/x-flac"],
@@ -1010,7 +1010,7 @@ def filescan(**kwargs):
                                        ScanPath(path = "", with_subdirs = False),
                                ],
                        name = "Music",
-                       description = "Play Music...",
+                       description = _("Play Music..."),
                        openfnc = filescan_open,
                )]
        try:
@@ -1022,7 +1022,7 @@ def filescan(**kwargs):
                                        ScanPath(path = "", with_subdirs = False),
                                ],
                        name = "Audio-CD",
-                       description = "Play Audio-CD...",
+                       description = _("Play Audio-CD..."),
                        openfnc = audioCD_open,
                ))
                return mediatypes
index 2c31197..0cefa35 100755 (executable)
@@ -23,16 +23,16 @@ def mountpoint_choosen(option):
 
        list = [ (r.description, r, res[r], session) for r in res ]
 
-       if list == [ ]:
+       if not list:
                from Screens.MessageBox import MessageBox
                if access(mountpoint, F_OK|R_OK):
-                       session.open(MessageBox, "No displayable files on this medium found!", MessageBox.TYPE_ERROR)
+                       session.open(MessageBox, _("No displayable files on this medium found!"), MessageBox.TYPE_ERROR)
                else:
                        print "ignore", mountpoint, "because its not accessible"
                return
 
        session.openWithCallback(execute, ChoiceBox, 
-               title = "The following files were found...",
+               title = _("The following files were found..."),
                list = list)
 
 def scan(session):
@@ -41,7 +41,7 @@ def scan(session):
        from Components.Harddisk import harddiskmanager
 
        parts = [ (r.description, r.mountpoint, session) for r in harddiskmanager.getMountedPartitions(onlyhotplug = False)]
-       if len(parts):
+       if parts:
                for x in parts:
                        if not access(x[1], F_OK|R_OK):
                                parts.remove(x) 
@@ -91,7 +91,7 @@ def autostart(reason, **kwargs):
 
 def Plugins(**kwargs):
        return [
-               PluginDescriptor(name="MediaScanner", description="Scan Files...", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main),
+               PluginDescriptor(name="MediaScanner", description=_("Scan Files..."), where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main),
 #              PluginDescriptor(where = PluginDescriptor.WHERE_MENU, fnc=menuHook),
                PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, fnc = sessionstart),
                PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart)
index 05adb63..10e4e51 100644 (file)
@@ -586,7 +586,7 @@ def filescan(**kwargs):
                                        ScanPath(path = "", with_subdirs = False),
                                ],
                        name = "Pictures", 
-                       description = "View Photos...",
+                       description = _("View Photos..."),
                        openfnc = filescan_open,
                )
 
index 4eadf2e..387c830 100644 (file)
@@ -22,6 +22,6 @@ def autostart(reason, **kwargs):
                socketHandler = SocketMMIMessageHandler()
 
 def Plugins(**kwargs):
-       return [ PluginDescriptor(name = "SocketMMI", description = "Python frontend for /tmp/mmi.socket", where = PluginDescriptor.WHERE_MENU, fnc = menu),
+       return [ PluginDescriptor(name = "SocketMMI", description = _("Python frontend for /tmp/mmi.socket"), where = PluginDescriptor.WHERE_MENU, fnc = menu),
                PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, fnc = sessionstart),
                PluginDescriptor(where = PluginDescriptor.WHERE_AUTOSTART, fnc = autostart) ]
index cbd6bc8..a479394 100644 (file)
@@ -623,7 +623,7 @@ class DiseqcTesterNimSelection(NimSelection):
        def showNim(self, nim):
                nimConfig = nimmanager.getNimConfig(nim.slot)
                if nim.isCompatible("DVB-S"):
-                       if nimConfig.configMode.value in ["loopthrough", "equal", "satposdepends", "nothing"]:
+                       if nimConfig.configMode.value in ("loopthrough", "equal", "satposdepends", "nothing"):
                                return False
                        if nimConfig.configMode.value == "simple":
                                if nimConfig.diseqcMode.value == "positioner":
index 947452e..327f08e 100755 (executable)
@@ -308,5 +308,3 @@ class RestoreScreen(Screen, ConfigListScreen):
        def runAsync(self, finished_cb):
                self.finished_cb = finished_cb
                self.doRestore()
-               
-       
\ No newline at end of file
index 6a85c4d..64f79e0 100644 (file)
@@ -67,7 +67,7 @@ class VideoHardware:
                else:
                        mode = config.av.videomode[port].value
                        force_widescreen = self.isWidescreenMode(port, mode)
-                       is_widescreen = force_widescreen or config.av.aspect.value in ["16_9", "16_10"]
+                       is_widescreen = force_widescreen or config.av.aspect.value in ("16_9", "16_10")
                        is_auto = config.av.aspect.value == "auto"
                        if is_widescreen:
                                if force_widescreen:
@@ -283,7 +283,7 @@ class VideoHardware:
 
                force_widescreen = self.isWidescreenMode(port, mode)
 
-               is_widescreen = force_widescreen or config.av.aspect.value in ["16_9", "16_10"]
+               is_widescreen = force_widescreen or config.av.aspect.value in ("16_9", "16_10")
                is_auto = config.av.aspect.value == "auto"
                policy2 = "policy" # use main policy
 
index 095e94c..8f8bea0 100644 (file)
@@ -165,7 +165,7 @@ class VideoWizard(WizardLanguage, Rc):
                        config.misc.showtestcard.value = False
 
        def keyNumberGlobal(self, number):
-               if number in [1,2,3]:
+               if number in (1,2,3):
                        if number == 1:
                                self.hw.saveMode("DVI", "720p", "multi")
                        elif number == 2:
index 30bdf79..5a7dfd1 100644 (file)
@@ -52,8 +52,9 @@ class VideoSetup(Screen, ConfigListScreen):
        def createSetup(self):
                level = config.usage.setup_level.index
 
-               self.list = [ ]
-               self.list.append(getConfigListEntry(_("Video Output"), config.av.videoport))
+               self.list = [
+                       getConfigListEntry(_("Video Output"), config.av.videoport)
+               ]
 
                # if we have modes for this port:
                if config.av.videoport.value in config.av.videomode:
@@ -76,9 +77,11 @@ class VideoSetup(Screen, ConfigListScreen):
                if not force_wide:
                        self.list.append(getConfigListEntry(_("Aspect Ratio"), config.av.aspect))
 
-               if force_wide or config.av.aspect.value in ["16_9", "16_10"]:
-                       self.list.append(getConfigListEntry(_("Display 4:3 content as"), config.av.policy_43))
-                       self.list.append(getConfigListEntry(_("Display >16:9 content as"), config.av.policy_169))
+               if force_wide or config.av.aspect.value in ("16_9", "16_10"):
+                       self.list.extend((
+                               getConfigListEntry(_("Display 4:3 content as"), config.av.policy_43),
+                               getConfigListEntry(_("Display >16:9 content as"), config.av.policy_169)
+                       ))
                elif config.av.aspect.value == "4_3":
                        self.list.append(getConfigListEntry(_("Display 16:9 content as"), config.av.policy_169))
 
index e184512..6cf0f7b 100644 (file)
@@ -25,7 +25,7 @@ class About(Screen):
                self["FPVersion"] = StaticText(fp_version)
 
                nims = nimmanager.nimList()
-               for count in range(4):
+               for count in (0, 1, 2, 3):
                        if count < len(nims):
                                self["Tuner" + str(count)] = StaticText(nims[count])
                        else:
@@ -33,7 +33,7 @@ class About(Screen):
 
                self["HDDHeader"] = StaticText(_("Detected HDD:"))
                hddlist = harddiskmanager.HDDList()
-               hdd = len(hddlist) > 0 and hddlist[0][1] or None
+               hdd = hddlist and hddlist[0][1] or None
                if hdd is not None and hdd.model() != "":
                        self["hddA"] = StaticText(_("%s\n(%s, %d MB free)") % (hdd.model(), hdd.capacity(),hdd.free()))
                else:
index ebfbe81..bae8f7d 100644 (file)
@@ -95,7 +95,7 @@ class ChannelContextMenu(Screen):
                inBouquet = csel.getMutableList() is not None
                haveBouquets = config.usage.multibouquet.value
 
-               if not (len(current_sel_path) or current_sel_flags & (eServiceReference.isDirectory|eServiceReference.isMarker)):
+               if not (current_sel_path or current_sel_flags & (eServiceReference.isDirectory|eServiceReference.isMarker)):
                        append_when_current_valid(current, menu, (_("show transponder info"), self.showServiceInformations), level = 2)
                if csel.bouquet_mark_edit == OFF and not csel.movemode:
                        if not inBouquetRootList:
@@ -558,7 +558,7 @@ class ChannelSelectionEdit:
                del self.servicePath[:] # remove all elements
                self.servicePath += self.savedPath # add saved elements
                del self.savedPath
-               self.setRoot(self.servicePath[len(self.servicePath)-1])
+               self.setRoot(self.servicePath[-1])
 
        def clearMarks(self):
                self.servicelist.clearMarks()
@@ -781,13 +781,13 @@ class ChannelSelectionBase(Screen):
 
        def getServiceName(self, ref):
                str = self.removeModeStr(ServiceReference(ref).getServiceName())
-               if not len(str):
+               if not str:
                        pathstr = ref.getPath()
-                       if pathstr.find('FROM PROVIDERS') != -1:
+                       if 'FROM PROVIDERS' in pathstr:
                                return _("Provider")
-                       if pathstr.find('FROM SATELLITES') != -1:
+                       if 'FROM SATELLITES' in pathstr:
                                return _("Satellites")
-                       if pathstr.find(') ORDER BY name') != -1:
+                       if ') ORDER BY name' in pathstr:
                                return _("All")
                return str
 
@@ -831,9 +831,8 @@ class ChannelSelectionBase(Screen):
 
        def pathUp(self, justSet=False):
                prev = self.servicePath.pop()
-               length = len(self.servicePath)
-               if length:
-                       current = self.servicePath[length-1]
+               if self.servicePath:
+                       current = self.servicePath[-1]
                        self.setRoot(current, justSet)
                        if not justSet:
                                self.setCurrentSelection(prev)
@@ -961,7 +960,7 @@ class ChannelSelectionBase(Screen):
                                self.enterPath(ref)
 
        def inBouquet(self):
-               if len(self.servicePath) > 0 and self.servicePath[0] == self.bouquet_root:
+               if self.servicePath and self.servicePath[0] == self.bouquet_root:
                        return True
                return False
 
@@ -1235,8 +1234,7 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
                del self.servicePath[:]
                self.servicePath += path
                self.saveRoot()
-               plen = len(path)
-               root = path[plen-1]
+               root = path[-1]
                cur_root = self.getRoot()
                if cur_root and cur_root != root:
                        self.setRoot(root)
@@ -1249,7 +1247,7 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
                for i in self.servicePath:
                        path += i.toString()
                        path += ';'
-               if len(path) and path != self.lastroot.value:
+               if path and path != self.lastroot.value:
                        self.lastroot.value = path
                        self.lastroot.save()
 
@@ -1259,7 +1257,7 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
                tmp = re.findall(self.lastroot.value)
                cnt = 0
                for i in tmp:
-                       self.servicePath.append(eServiceReference(i[:len(i)-1]))
+                       self.servicePath.append(eServiceReference(i[:-1]))
                        cnt += 1
                if cnt:
                        path = self.servicePath.pop()
@@ -1269,7 +1267,7 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
                        self.saveRoot()
 
        def preEnterPath(self, refstr):
-               if len(self.servicePath) and self.servicePath[0] != eServiceReference(refstr):
+               if self.servicePath and self.servicePath[0] != eServiceReference(refstr):
                        pathstr = self.lastroot.value
                        if pathstr is not None and pathstr.find(refstr) == 0:
                                self.restoreRoot()
@@ -1289,16 +1287,14 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
                        self.lastservice.save()
 
        def setCurrentServicePath(self, path):
-               hlen = len(self.history)
-               if hlen > 0:
+               if self.history:
                        self.history[self.history_pos] = path
                else:
                        self.history.append(path)
                self.setHistoryPath()
 
        def getCurrentServicePath(self):
-               hlen = len(self.history)
-               if hlen > 0:
+               if self.history:
                        return self.history[self.history_pos]
                return None
 
@@ -1411,7 +1407,7 @@ class ChannelSelectionRadio(ChannelSelectionBase, ChannelSelectionEdit, ChannelS
                for i in self.servicePathRadio:
                        path += i.toString()
                        path += ';'
-               if len(path) and path != config.radio.lastroot.value:
+               if path and path != config.radio.lastroot.value:
                        config.radio.lastroot.value = path
                        config.radio.lastroot.save()
 
@@ -1421,7 +1417,7 @@ class ChannelSelectionRadio(ChannelSelectionBase, ChannelSelectionEdit, ChannelS
                tmp = re.findall(config.radio.lastroot.value)
                cnt = 0
                for i in tmp:
-                       self.servicePathRadio.append(eServiceReference(i[:len(i)-1]))
+                       self.servicePathRadio.append(eServiceReference(i[:-1]))
                        cnt += 1
                if cnt:
                        path = self.servicePathRadio.pop()
@@ -1431,7 +1427,7 @@ class ChannelSelectionRadio(ChannelSelectionBase, ChannelSelectionEdit, ChannelS
                        self.saveRoot()
 
        def preEnterPath(self, refstr):
-               if len(self.servicePathRadio) and self.servicePathRadio[0] != eServiceReference(refstr):
+               if self.servicePathRadio and self.servicePathRadio[0] != eServiceReference(refstr):
                        pathstr = config.radio.lastroot.value
                        if pathstr is not None and pathstr.find(refstr) == 0:
                                self.restoreRoot()
index 5028301..a997f7f 100644 (file)
@@ -121,7 +121,7 @@ class MMIDialog(Screen):
                elif self.tag == "WAIT":
                        self.handler.stopMMI(self.slotid)
                        self.closeMmi()
-               elif self.tag in [ "MENU", "LIST" ]:
+               elif self.tag in ( "MENU", "LIST" ):
                        print "cancel list"
                        self.handler.answerMenu(self.slotid, 0)
                        self.showWait()
index c6b156c..2058c04 100644 (file)
@@ -11,7 +11,6 @@ class Console(Screen):
                </screen>"""
                
        def __init__(self, session, title = "Console", cmdlist = None, finishedCallback = None, closeOnSuccess = False):
-               self.skin = Console.skin
                Screen.__init__(self, session)
 
                self.finishedCallback = finishedCallback
@@ -68,4 +67,4 @@ class Console(Screen):
                        self.container.dataAvail.remove(self.dataAvail)
 
        def dataAvail(self, str):
-               self["text"].setText(self["text"].getText() + str)
\ No newline at end of file
+               self["text"].setText(self["text"].getText() + str)
index 9883dc8..73b07ac 100644 (file)
@@ -96,8 +96,6 @@ def filescan_open(list, session, **kwargs):
 
 def filescan(**kwargs):
        from Components.Scanner import Scanner, ScanPath
-       from mimetypes import add_type
-       add_type("application/x-dream-package", "dmpkg")
        return \
                Scanner(mimetypes = ["application/x-dream-package"], 
                        paths_to_scan = 
@@ -106,7 +104,7 @@ def filescan(**kwargs):
                                        ScanPath(path = "", with_subdirs = False), 
                                ], 
                        name = "Dream-Package", 
-                       description = "Install settings, skins, software...", 
+                       description = _("Install settings, skins, software..."), 
                        openfnc = filescan_open, )
 
 print "add dreampackage scanner plugin"
index e7388fc..ae96333 100644 (file)
@@ -68,7 +68,7 @@ class EPGSelection(Screen):
                self["key_green"] = Button(_("Add timer"))
                self.key_green_choice = self.ADD_TIMER
                self.key_red_choice = self.EMPTY
-               self["list"] = EPGList(type = self.type, selChangedCB = self.onSelectionChanged, timer = self.session.nav.RecordTimer)
+               self["list"] = EPGList(type = self.type, selChangedCB = self.onSelectionChanged, timer = session.nav.RecordTimer)
 
                self["actions"] = ActionMap(["EPGSelectActions", "OkCancelActions"],
                        {
index 6aed1e1..c55d952 100644 (file)
@@ -20,7 +20,7 @@ class EventViewBase:
                self.similarEPGCB = similarEPGCB
                self.cbFunc = callback
                self.currentService=Ref
-               self.isRecording = (not Ref.ref.flags & eServiceReference.isGroup) and len(Ref.ref.getPath())
+               self.isRecording = (not Ref.ref.flags & eServiceReference.isGroup) and Ref.ref.getPath()
                self.event = Event
                self["epg_description"] = ScrollLabel()
                self["datetime"] = Label()
@@ -134,12 +134,12 @@ class EventViewBase:
                text = event.getEventName()
                short = event.getShortDescription()
                ext = event.getExtendedDescription()
-               if len(short) > 0 and short != text:
-                       text = text + '\n\n' + short
-               if len(ext) > 0:
-                       if len(text) > 0:
-                               text = text + '\n\n'
-                       text = text + ext
+               if short and short != text:
+                       text += '\n\n' + short
+               if ext:
+                       if text:
+                               text += '\n\n'
+                       text += ext
 
                self.setTitle(event.getEventName())
                self["epg_description"].setText(text)
@@ -189,7 +189,7 @@ class EventViewBase:
                        self["key_red"].setText(_("Similar"))
 
        def openSimilarList(self):
-               if self.similarEPGCB is not None and len(self["key_red"].getText()):
+               if self.similarEPGCB is not None and self["key_red"].getText():
                        id = self.event and self.event.getEventId()
                        refstr = str(self.currentService)
                        if id is not None:
index 19a674e..c9f069f 100644 (file)
@@ -39,7 +39,7 @@ class HarddiskSetup(Screen):
                Screen.__init__(self, session)
                self.hdd = hdd
 
-               if type not in [self.HARDDISK_INITIALIZE, self.HARDDISK_CHECK]:
+               if type not in (self.HARDDISK_INITIALIZE, self.HARDDISK_CHECK):
                        self.type = self.HARDDISK_INITIALIZE
                else:
                        self.type = type
index abef38d..74882a3 100644 (file)
@@ -29,13 +29,13 @@ class HelpMenu(Screen, Rc):
                #arrow = self["arrowup"]
                print "selection:", selection
 
-               if selection and len(selection) > 1 and selection[1] == "SHIFT":
-                       self.selectKey("SHIFT")
-
-               if selection and len(selection) > 1 and selection[1] == "long":
-                       self["long_key"].setText(_("Long Keypress"))
-               else:
-                       self["long_key"].setText("")
+               longText = ""
+               if selection and len(selection) > 1:
+                       if selection[1] == "SHIFT":
+                               self.selectKey("SHIFT")
+                       elif selection[1] == "long":
+                               longText = _("Long Keypress")
+               self["long_key"].setText(longText)
 
                self.selectKey(selection[0])
                #if selection is None:
@@ -55,6 +55,6 @@ class HelpableScreen:
                self.session.openWithCallback(self.callHelpAction, HelpMenu, self.helpList)
 
        def callHelpAction(self, *args):
-               if len(args):
+               if args:
                        (actionmap, context, action) = args
                        actionmap.action(context, action)
index bd9ea18..4d92bd3 100644 (file)
@@ -148,8 +148,8 @@ class MoviePlayer(InfoBarBase, InfoBarShowHide, \
                                InfoBarPlugins:
                        x.__init__(self)
 
-               self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()
-               self.session.nav.playService(service)
+               self.lastservice = session.nav.getCurrentlyPlayingServiceReference()
+               session.nav.playService(service)
                self.returning = False
                self.onClose.append(self.__onClose)
 
index 3f9fe21..e39e028 100644 (file)
@@ -369,25 +369,27 @@ class InfoBarSimpleEventView:
                        })
 
        def openEventView(self):
-               self.epglist = [ ]
+               epglist = [ ]
+               self.epglist = epglist
                service = self.session.nav.getCurrentService()
                ref = self.session.nav.getCurrentlyPlayingServiceReference()
                info = service.info()
                ptr=info.getEvent(0)
                if ptr:
-                       self.epglist.append(ptr)
+                       epglist.append(ptr)
                ptr=info.getEvent(1)
                if ptr:
-                       self.epglist.append(ptr)
-               if len(self.epglist) > 0:
-                       self.session.open(EventViewSimple, self.epglist[0], ServiceReference(ref), self.eventViewCallback)
+                       epglist.append(ptr)
+               if epglist:
+                       self.session.open(EventViewSimple, epglist[0], ServiceReference(ref), self.eventViewCallback)
 
        def eventViewCallback(self, setEvent, setService, val): #used for now/next displaying
-               if len(self.epglist) > 1:
-                       tmp = self.epglist[0]
-                       self.epglist[0]=self.epglist[1]
-                       self.epglist[1]=tmp
-                       setEvent(self.epglist[0])
+               epglist = self.epglist
+               if len(epglist) > 1:
+                       tmp = epglist[0]
+                       epglist[0] = epglist[1]
+                       epglist[1] = tmp
+                       setEvent(epglist[0])
 
 class InfoBarEPG:
        """ EPG - Opens an EPG list when the showEPGList action fires """
@@ -440,7 +442,7 @@ class InfoBarEPG:
 
        def openBouquetEPG(self, bouquet, withCallback=True):
                services = self.getBouquetServices(bouquet)
-               if len(services):
+               if services:
                        self.epg_bouquet = bouquet
                        if withCallback:
                                self.dlg_stack.append(self.session.openWithCallback(self.closed, EPGSelection, services, self.zapToService, None, self.changeBouquetCB))
@@ -455,7 +457,7 @@ class InfoBarEPG:
                                self.bouquetSel.up()
                        bouquet = self.bouquetSel.getCurrent()
                        services = self.getBouquetServices(bouquet)
-                       if len(services):
+                       if services:
                                self.epg_bouquet = bouquet
                                epg.setServices(services)
 
@@ -642,9 +644,9 @@ class InfoBarSeek:
                                        return 1
                                elif action[:8] == "seekdef:":
                                        key = int(action[8:])
-                                       time = [-config.seek.selfdefined_13.value, False, config.seek.selfdefined_13.value,
+                                       time = (-config.seek.selfdefined_13.value, False, config.seek.selfdefined_13.value,
                                                -config.seek.selfdefined_46.value, False, config.seek.selfdefined_46.value,
-                                               -config.seek.selfdefined_79.value, False, config.seek.selfdefined_79.value][key-1]
+                                               -config.seek.selfdefined_79.value, False, config.seek.selfdefined_79.value)[key-1]
                                        self.screen.doSeekRelative(time * 90000)
                                        return 1                                        
                                else:
@@ -772,7 +774,7 @@ class InfoBarSeek:
                        return False
 
                if not self.isSeekable():
-                       if state not in [self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE]:
+                       if state not in (self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE):
                                state = self.SEEK_STATE_PLAY
 
                pauseable = service.pause()
@@ -885,30 +887,31 @@ class InfoBarSeek:
                        self.setSeekState(self.makeStateSlowMotion(speed))
 
        def seekBack(self):
-               if self.seekstate == self.SEEK_STATE_PLAY:
+               seekstate = self.seekstate
+               if seekstate == self.SEEK_STATE_PLAY:
                        self.setSeekState(self.makeStateBackward(int(config.seek.enter_backward.value)))
-               elif self.seekstate == self.SEEK_STATE_EOF:
+               elif seekstate == self.SEEK_STATE_EOF:
                        self.setSeekState(self.makeStateBackward(int(config.seek.enter_backward.value)))
                        self.doSeekRelative(-6)
-               elif self.seekstate == self.SEEK_STATE_PAUSE:
+               elif seekstate == self.SEEK_STATE_PAUSE:
                        self.doSeekRelative(-3)
-               elif self.isStateForward(self.seekstate):
-                       speed = self.seekstate[1]
-                       if self.seekstate[2]:
-                               speed /= self.seekstate[2]
+               elif self.isStateForward(seekstate):
+                       speed = seekstate[1]
+                       if seekstate[2]:
+                               speed /= seekstate[2]
                        speed = self.getLower(speed, config.seek.speeds_forward.value)
                        if speed:
                                self.setSeekState(self.makeStateForward(speed))
                        else:
                                self.setSeekState(self.SEEK_STATE_PLAY)
-               elif self.isStateBackward(self.seekstate):
-                       speed = -self.seekstate[1]
-                       if self.seekstate[2]:
-                               speed /= self.seekstate[2]
+               elif self.isStateBackward(seekstate):
+                       speed = -seekstate[1]
+                       if seekstate[2]:
+                               speed /= seekstate[2]
                        speed = self.getHigher(speed, config.seek.speeds_backward.value) or config.seek.speeds_backward.value[-1]
                        self.setSeekState(self.makeStateBackward(speed))
-               elif self.isStateSlowMotion(self.seekstate):
-                       speed = self.getHigher(self.seekstate[2], config.seek.speeds_slowmotion.value)
+               elif self.isStateSlowMotion(seekstate):
+                       speed = self.getHigher(seekstate[2], config.seek.speeds_slowmotion.value)
                        if speed:
                                self.setSeekState(self.makeStateSlowMotion(speed))
                        else:
@@ -994,7 +997,7 @@ class InfoBarSeek:
                self.eofState = 0
                if not self.seekstate == self.SEEK_STATE_PAUSE:
                        self.setSeekState(self.SEEK_STATE_EOF)
-               if eofstate == -1 or not seekstate in [self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE]:
+               if eofstate == -1 or not seekstate in (self.SEEK_STATE_PLAY, self.SEEK_STATE_PAUSE):
                        seekable = self.getSeek()
                        if seekable is not None:
                                seekable.seekTo(-1)
@@ -1480,7 +1483,7 @@ class InfoBarInstantRecord:
 
        def isInstantRecordRunning(self):
                print "self.recording:", self.recording
-               if len(self.recording) > 0:
+               if self.recording:
                        for x in self.recording:
                                if x.isRunning():
                                        return True
@@ -1631,13 +1634,13 @@ class InfoBarAudioSelection:
                                        break
 
                        if SystemInfo["CanDownmixAC3"]:
-                               tlist = [(_("AC3 downmix") + " - " +[_("Off"), _("On")][config.av.downmix_ac3.value and 1 or 0], "CALLFUNC", self.changeAC3Downmix),
-                                       ([_("Left"), _("Stereo"), _("Right")][self.audioChannel.getCurrentChannel()], "mode"),
+                               tlist = [(_("AC3 downmix") + " - " +(_("Off"), _("On"))[config.av.downmix_ac3.value and 1 or 0], "CALLFUNC", self.changeAC3Downmix),
+                                       ((_("Left"), _("Stereo"), _("Right"))[self.audioChannel.getCurrentChannel()], "mode"),
                                        ("--", "")] + tlist
                                keys = [ "red", "green", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + [""]*n
                                selection += 3
                        else:
-                               tlist = [([_("Left"), _("Stereo"), _("Right")][self.audioChannel.getCurrentChannel()], "mode"), ("--", "")] + tlist
+                               tlist = [((_("Left"), _("Stereo"), _("Right"))[self.audioChannel.getCurrentChannel()], "mode"), ("--", "")] + tlist
                                keys = [ "red", "", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] + [""]*n
                                selection += 2
                        self.session.openWithCallback(self.audioSelected, ChoiceBox, title=_("Select audio track"), list = tlist, selection = selection, keys = keys)
@@ -1649,7 +1652,7 @@ class InfoBarAudioSelection:
                list = choicelist.list
                t = list[0][1]
                list[0][1]=(t[0], t[1], t[2], t[3], t[4], t[5], t[6],
-                       _("AC3 downmix") + " - " +[_("On"), _("Off")][config.av.downmix_ac3.value and 1 or 0])
+                       _("AC3 downmix") + " - " + (_("On"), _("Off"))[config.av.downmix_ac3.value and 1 or 0])
                choicelist.setList(list)
                if config.av.downmix_ac3.value:
                        config.av.downmix_ac3.value = False
@@ -2080,9 +2083,6 @@ class InfoBarSummary(Screen):
 #                      <convert type="ServiceName">Reference</convert>
 #              </widget>
 
-       def __init__(self, session, parent):
-               Screen.__init__(self, session, parent = parent)
-
 class InfoBarSummarySupport:
        def __init__(self):
                pass
@@ -2108,9 +2108,6 @@ class InfoBarMoviePlayerSummary(Screen):
                </widget>
        </screen>"""
 
-       def __init__(self, session, parent):
-               Screen.__init__(self, session)
-
 class InfoBarMoviePlayerSummarySupport:
        def __init__(self):
                pass
@@ -2211,7 +2208,7 @@ class InfoBarServiceErrorPopupSupport:
                else:
                        self.last_error = error
 
-               errors = {
+               error = {
                        eDVBServicePMTHandler.eventNoResources: _("No free tuner!"),
                        eDVBServicePMTHandler.eventTuneFailed: _("Tune failed!"),
                        eDVBServicePMTHandler.eventNoPAT: _("No data on transponder!\n(Timeout reading PAT)"),
@@ -2222,9 +2219,7 @@ class InfoBarServiceErrorPopupSupport:
                        eDVBServicePMTHandler.eventSOF: None,
                        eDVBServicePMTHandler.eventEOF: None,
                        eDVBServicePMTHandler.eventMisconfiguration: _("Service unavailable!\nCheck tuner configuration!"),
-               }
-
-               error = errors.get(error) #this returns None when the key not exist in the dict
+               }.get(error) #this returns None when the key not exist in the dict
 
                if error is not None:
                        Notifications.AddPopup(text = error, type = MessageBox.TYPE_ERROR, timeout = 5, id = "ZapError")
index 94ede08..082daa5 100644 (file)
@@ -76,21 +76,22 @@ class LanguageSelection(Screen):
                print "ok"
 
        def updateList(self):
-               first_time = len(self.list) == 0
+               first_time = not self.list
 
-               self.list = []
-               if len(language.getLanguageList()) == 0: # no language available => display only english
-                       self.list.append(LanguageEntryComponent("en", _cached("en_EN"), "en_EN"))
+               languageList = language.getLanguageList()
+               if not languageList: # no language available => display only english
+                       list = [ LanguageEntryComponent("en", _cached("en_EN"), "en_EN") ]
                else:
-                       for x in language.getLanguageList():
-                               self.list.append(LanguageEntryComponent(file = x[1][2].lower(), name = _cached("%s_%s" % x[1][1:3]), index = x[0]))
-               #self.list.sort(key=lambda x: x[1][7])
+                       list = [ LanguageEntryComponent(file = x[1][2].lower(), name = _cached("%s_%s" % x[1][1:3]), index = x[0]) for x in languageList]
+               self.list = list
+
+               #list.sort(key=lambda x: x[1][7])
 
                print "updateList"
                if first_time:
-                       self["languages"].list = self.list
+                       self["languages"].list = list
                else:
-                       self["languages"].updateList(self.list)
+                       self["languages"].updateList(list)
                print "done"
 
        def changed(self):
index fa47b1f..61d7105 100644 (file)
@@ -163,11 +163,11 @@ class LocationBox(Screen, NumericalTextInput, HelpableScreen):
                })
 
                # Run some functions when shown
-               self.onShown.extend([
+               self.onShown.extend((
                        boundFunction(self.setTitle, windowTitle),
                        self.updateTarget,
                        self.showHideRename,
-               ])
+               ))
 
                self.onLayoutFinish.append(self.switchToFileListOnStart)
  
@@ -241,7 +241,7 @@ class LocationBox(Screen, NumericalTextInput, HelpableScreen):
                        )
 
        def createDirCallback(self, res):
-               if res is not None and len(res):
+               if res:
                        path = os.path.join(self["filelist"].current_directory, res)
                        if not pathExists(path):
                                if not createDir(path):
@@ -454,7 +454,7 @@ class LocationBox(Screen, NumericalTextInput, HelpableScreen):
 
        def selectByStart(self):
                # Don't do anything on initial call
-               if not len(self.quickselect):
+               if not self.quickselect:
                        return
 
                # Don't select if no dir
@@ -503,16 +503,12 @@ class LocationBox(Screen, NumericalTextInput, HelpableScreen):
                return str(type(self)) + "(" + self.text + ")"
 
 class MovieLocationBox(LocationBox):
-       skinName = "LocationBox"
-
        def __init__(self, session, text, dir, minFree = None):
                inhibitDirs = ["/bin", "/boot", "/dev", "/etc", "/lib", "/proc", "/sbin", "/sys", "/usr", "/var"]
                LocationBox.__init__(self, session, text = text, currDir = dir, bookmarks = config.movielist.videodirs, autoAdd = True, editDir = True, inhibitDirs = inhibitDirs, minFree = minFree)
+               self.skinName = "LocationBox"
 
 class TimeshiftLocationBox(LocationBox):
-
-       skinName = "LocationBox" # XXX: though we could use a custom skin or inherit the hardcoded one we stick with the original :-)
-
        def __init__(self, session):
                inhibitDirs = ["/bin", "/boot", "/dev", "/etc", "/lib", "/proc", "/sbin", "/sys", "/usr", "/var"]
                LocationBox.__init__(
@@ -524,8 +520,9 @@ class TimeshiftLocationBox(LocationBox):
                                autoAdd = True,
                                editDir = True,
                                inhibitDirs = inhibitDirs,
-                               minFree = 1024 # XXX: the same requirement is hardcoded in servicedvb.cpp
+                               minFree = 1024 # the same requirement is hardcoded in servicedvb.cpp
                )
+               self.skinName = "LocationBox"
 
        def cancel(self):
                config.usage.timeshift_path.cancel()
index 93f23df..5f2032f 100644 (file)
@@ -61,9 +61,6 @@ class MenuSummary(Screen):
                </widget>
        </screen>"""
 
-       def __init__(self, session, parent):
-               Screen.__init__(self, session, parent)
-
 class Menu(Screen):
 
        ALLOW_SUSPEND = True
@@ -118,7 +115,7 @@ class Menu(Screen):
                self.menuClosed(*res)
 
        def menuClosed(self, *res):
-               if len(res) and res[0]:
+               if res and res[0]:
                        self.close(True)
 
        def addItem(self, destList, node):
index 8a5989c..1048568 100644 (file)
@@ -43,7 +43,7 @@ class MessageBox(Screen):
                        else:
                                self.list = [ (_("no"), 1), (_("yes"), 0) ]
                
-               if len(self.list):
+               if self.list:
                        self["selectedChoice"].setText(self.list[0][0])
                self["list"] = MenuList(self.list)
 
@@ -134,7 +134,7 @@ class MessageBox(Screen):
                if self.close_on_any_key:
                        self.close(True)
                self["list"].instance.moveSelection(direction)
-               if len(self.list):
+               if self.list:
                        self["selectedChoice"].setText(self["list"].getCurrent()[0])
                self.stopTimer()
 
index 5951653..174a4f0 100644 (file)
@@ -65,20 +65,20 @@ class MovieContextMenu(Screen):
                        })
 
                menu = [(_("delete..."), self.delete)]
-               
-               for p in plugins.getPlugins(PluginDescriptor.WHERE_MOVIELIST):
-                       menu.append((p.description, boundFunction(self.execPlugin, p)))
-               
+               menu.extend([(p.description, boundFunction(self.execPlugin, p)) for p in plugins.getPlugins(PluginDescriptor.WHERE_MOVIELIST)])
+
                if config.movielist.moviesort.value == MovieList.SORT_ALPHANUMERIC:
                        menu.append((_("sort by date"), boundFunction(self.sortBy, MovieList.SORT_RECORDED)))
                else:
                        menu.append((_("alphabetic sort"), boundFunction(self.sortBy, MovieList.SORT_ALPHANUMERIC)))
                
-               menu.append((_("list style default"), boundFunction(self.listType, MovieList.LISTTYPE_ORIGINAL)))
-               menu.append((_("list style compact with description"), boundFunction(self.listType, MovieList.LISTTYPE_COMPACT_DESCRIPTION)))
-               menu.append((_("list style compact"), boundFunction(self.listType, MovieList.LISTTYPE_COMPACT)))
-               menu.append((_("list style single line"), boundFunction(self.listType, MovieList.LISTTYPE_MINIMAL)))
-               
+               menu.extend((
+                       (_("list style default"), boundFunction(self.listType, MovieList.LISTTYPE_ORIGINAL)),
+                       (_("list style compact with description"), boundFunction(self.listType, MovieList.LISTTYPE_COMPACT_DESCRIPTION)),
+                       (_("list style compact"), boundFunction(self.listType, MovieList.LISTTYPE_COMPACT)),
+                       (_("list style single line"), boundFunction(self.listType, MovieList.LISTTYPE_MINIMAL))
+               ))
+
                if config.movielist.description.value == MovieList.SHOW_DESCRIPTION:
                        menu.append((_("hide extended description"), boundFunction(self.showDescription, MovieList.HIDE_DESCRIPTION)))
                else:
index f64be90..f80267a 100644 (file)
@@ -1,6 +1,5 @@
 from Screen import Screen
 
 class Mute(Screen):
-       def __init__(self, session):
-               Screen.__init__(self, session)
+       pass
 
index ea2d17e..50f8c41 100755 (executable)
@@ -28,8 +28,10 @@ class InterfaceList(MenuList):
                self.l.setItemHeight(30)
 
 def InterfaceEntryComponent(index,name,default,active ):
-       res = [ (index) ]
-       res.append(MultiContentEntryText(pos=(80, 5), size=(430, 25), font=0, text=name))
+       res = [
+               (index),
+               MultiContentEntryText(pos=(80, 5), size=(430, 25), font=0, text=name)
+       ]
        num_configured_if = len(iNetwork.getConfiguredAdapters())
        if num_configured_if >= 2:
                if default is True:
@@ -62,7 +64,7 @@ class NetworkAdapterSelection(Screen,HelpableScreen):
                
                self.adapters = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()]
                
-               if len(self.adapters) == 0:
+               if not self.adapters:
                        self.onFirstExecBegin.append(self.NetworkFallback)
                        
                self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
@@ -232,17 +234,16 @@ class NameserverSetup(Screen, ConfigListScreen, HelpableScreen):
 
        def createConfig(self):
                self.nameservers = iNetwork.getNameserverList()
-               self.nameserverEntries = []
-               
-               for nameserver in self.nameservers:
-                       self.nameserverEntries.append(NoSave(ConfigIP(default=nameserver)))
+               self.nameserverEntries = [ NoSave(ConfigIP(default=nameserver)) for nameserver in self.nameservers]
 
        def createSetup(self):
                self.list = []
-               
-               for i in range(len(self.nameserverEntries)):
-                       self.list.append(getConfigListEntry(_("Nameserver %d") % (i + 1), self.nameserverEntries[i]))
-               
+
+               i = 1
+               for x in self.nameserverEntries:
+                       self.list.append(getConfigListEntry(_("Nameserver %d") % (i), x))
+                       i += 1
+
                self["config"].list = self.list
                self["config"].l.setList(self.list)
 
index 39c644b..e097958 100644 (file)
@@ -4,7 +4,7 @@ from Components.Label import Label
 class NumericalTextInputHelpDialog(Screen):
        def __init__(self, session, textinput):
                Screen.__init__(self, session)
-               for x in range(1, 10):
+               for x in (1, 2, 3, 4, 5, 6, 7, 8, 9):
                        self["key%d" % x] = Label(text=textinput.mapping[x].encode("utf-8"))
                self.last_marked = 0
 
index 8b90c42..891379c 100644 (file)
@@ -8,5 +8,5 @@ class PVRState(Screen):
                self["state"] = Label(text="")
 
 class TimeshiftState(PVRState):
-       def __init__(self, session):
-               PVRState.__init__(self, session)
+       pass
+
index 6ae12ca..4c63dd5 100644 (file)
@@ -215,9 +215,7 @@ class ParentalControlEditor(Screen):
                if result is not None:
                        print "result:", result
                        self.currentLetter = result[1]
-                       self.list = []
-                       for x in self.servicesList[result[1]]:
-                               self.list.append(ParentalControlEntryComponent(x[0], x[1], parentalControl.getProtectionLevel(x[0]) != -1))
+                       self.list = [ParentalControlEntryComponent(x[0], x[1], parentalControl.getProtectionLevel(x[0]) != -1) for x in self.servicesList[result[1]]]
                        self.servicelist.setList(self.list)
                else:
                        parentalControl.save()
index 0f6ee74..cd17e2e 100644 (file)
@@ -51,11 +51,9 @@ class PluginBrowser(Screen):
                plugin(session=self.session)
                
        def updateList(self):
-               self.list = [ ]
                self.pluginlist = plugins.getPlugins(PluginDescriptor.WHERE_PLUGINMENU)
-               for plugin in self.pluginlist:
-                       self.list.append(PluginEntryComponent(plugin))
-               
+               self.list = [PluginEntryComponent(plugin) for plugin in self.pluginlist]
+
                self["list"].l.setList(self.list)
 
        def delete(self):
@@ -187,7 +185,7 @@ class PluginDownloadBrowser(Screen):
                                                self.pluginlist.append(plugin)
        
        def updateList(self):
-               self.list = []
+               list = []
                expandableIcon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/expandable-plugins.png"))
                expandedIcon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/expanded-plugins.png"))
                verticallineIcon = LoadPixmap(resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/verticalline-plugins.png"))
@@ -204,10 +202,10 @@ class PluginDownloadBrowser(Screen):
                        
                for x in self.plugins.keys():
                        if x in self.expanded:
-                               self.list.append(PluginCategoryComponent(x, expandedIcon))
-                               for plugin in self.plugins[x]:
-                                       self.list.append(PluginDownloadComponent(plugin[0], plugin[1]))
+                               list.append(PluginCategoryComponent(x, expandedIcon))
+                               list.extend([PluginDownloadComponent(plugin[0], plugin[1]) for plugin in self.plugins[x]])
                        else:
-                               self.list.append(PluginCategoryComponent(x, expandableIcon))
-               self["list"].l.setList(self.list)
+                               list.append(PluginCategoryComponent(x, expandableIcon))
+               self.list = list
+               self["list"].l.setList(list)
 
index 3a7c78b..27ba1ab 100644 (file)
@@ -81,4 +81,3 @@ class Rc:
                for selectPic in self.selectpics:
                        for pic in selectPic[1]:
                                self[pic].hide()
-       
\ No newline at end of file
index da6fcc1..8b5089a 100644 (file)
@@ -21,7 +21,7 @@ class NimSetup(Screen, ConfigListScreen):
                else:
                        list.append(getConfigListEntry(_("Port A"), nim.diseqcA))
 
-               if mode in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
+               if mode in ("toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
                        list.append(getConfigListEntry(_("Port B"), nim.diseqcB))
                        if mode == "diseqc_a_b_c_d":
                                list.append(getConfigListEntry(_("Port C"), nim.diseqcC))
@@ -99,7 +99,7 @@ class NimSetup(Screen, ConfigListScreen):
                        if self.nimConfig.configMode.value == "simple":                 #simple setup
                                self.diseqcModeEntry = getConfigListEntry(_("Mode"), self.nimConfig.diseqcMode)
                                self.list.append(self.diseqcModeEntry)
-                               if self.nimConfig.diseqcMode.value in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
+                               if self.nimConfig.diseqcMode.value in ("single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
                                        self.createSimpleSetup(self.list, self.nimConfig.diseqcMode.value)
                                if self.nimConfig.diseqcMode.value == "positioner":
                                        self.createPositionerSetup(self.list)
@@ -204,7 +204,7 @@ class NimSetup(Screen, ConfigListScreen):
                if self.have_advanced and self.nim.config_mode == "advanced":
                        self.fillAdvancedList()
                for x in self.list:
-                       if x in [self.turnFastEpochBegin, self.turnFastEpochEnd]:
+                       if x in (self.turnFastEpochBegin, self.turnFastEpochEnd):
                                # workaround for storing only hour*3600+min*60 value in configfile
                                # not really needed.. just for cosmetics..
                                tm = localtime(x[1].value)
@@ -453,7 +453,7 @@ class NimSelection(Screen):
                        text = nimConfig.configMode.value
                        if self.showNim(x):
                                if x.isCompatible("DVB-S"):
-                                       if nimConfig.configMode.value in ["loopthrough", "equal", "satposdepends"]:
+                                       if nimConfig.configMode.value in ("loopthrough", "equal", "satposdepends"):
                                                text = { "loopthrough": _("loopthrough to"),
                                                                 "equal": _("equal to"),
                                                                 "satposdepends": _("second cable of motorized LNB") } [nimConfig.configMode.value]
@@ -461,11 +461,11 @@ class NimSelection(Screen):
                                        elif nimConfig.configMode.value == "nothing":
                                                text = _("nothing connected")
                                        elif nimConfig.configMode.value == "simple":
-                                               if nimConfig.diseqcMode.value in ["single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
+                                               if nimConfig.diseqcMode.value in ("single", "toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
                                                        text = _("Sats") + ": " 
                                                        if nimConfig.diseqcA.orbital_position != 3601:
                                                                text += nimmanager.getSatName(int(nimConfig.diseqcA.value))
-                                                       if nimConfig.diseqcMode.value in ["toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"]:
+                                                       if nimConfig.diseqcMode.value in ("toneburst_a_b", "diseqc_a_b", "diseqc_a_b_c_d"):
                                                                if nimConfig.diseqcB.orbital_position != 3601:
                                                                        text += "," + nimmanager.getSatName(int(nimConfig.diseqcB.value))
                                                        if nimConfig.diseqcMode.value == "diseqc_a_b_c_d":
@@ -491,4 +491,4 @@ class NimSelection(Screen):
                                        
                                self.list.append((slotid, x.friendly_full_description, text, x))
                self["nimlist"].setList(self.list)
-               self["nimlist"].updateList(self.list)
\ No newline at end of file
+               self["nimlist"].updateList(self.list)
index df8af4b..fa2f447 100644 (file)
@@ -19,11 +19,6 @@ def to_unsigned(x):
        return x & 0xFFFFFFFF
 
 def ServiceInfoListEntry(a, b, valueType=TYPE_TEXT, param=4):
-       res = [ ]
-
-       #PyObject *type, *px, *py, *pwidth, *pheight, *pfnt, *pstring, *pflags;
-       res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 30, 0, RT_HALIGN_LEFT, ""))
-       res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 25, 0, RT_HALIGN_LEFT, a))
        print "b:", b
        if not isinstance(b, str):
                if valueType == TYPE_VALUE_HEX:
@@ -34,10 +29,13 @@ def ServiceInfoListEntry(a, b, valueType=TYPE_TEXT, param=4):
                        b = ("0x%0" + str(param) + "x (%dd)") % (to_unsigned(b), b)
                else:
                        b = str(b)
-       
-       res.append((eListboxPythonMultiContent.TYPE_TEXT, 220, 0, 350, 25, 0, RT_HALIGN_LEFT, b))
 
-       return res
+       return [
+               #PyObject *type, *px, *py, *pwidth, *pheight, *pfnt, *pstring, *pflags;
+               (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 30, 0, RT_HALIGN_LEFT, ""),
+               (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 200, 25, 0, RT_HALIGN_LEFT, a),
+               (eListboxPythonMultiContent.TYPE_TEXT, 220, 0, 350, 25, 0, RT_HALIGN_LEFT, b)
+       ]
 
 class ServiceInfoList(HTMLComponent, GUIComponent):
        def __init__(self, source):
@@ -151,9 +149,7 @@ class ServiceInfo(Screen):
                                                 "transmission_mode": _("Transmission Mode"),
                                                 "guard_interval"       : _("Guard Interval"),
                                                 "hierarchy_information": _("Hierarchy Information") }
-                               Labels = [ ]
-                               for i in tp_info.keys():
-                                       Labels.append( (conv[i], tp_info[i], TYPE_VALUE_DEC) )
+                               Labels = [(conv[i], tp_info[i], TYPE_VALUE_DEC) for i in tp_info.keys()]
                                self.fillList(Labels)
 
        def pids(self):
@@ -186,7 +182,7 @@ class ServiceInfo(Screen):
                if frontendDataOrg and len(frontendDataOrg):
                        frontendData = ConvertToHumanReadable(frontendDataOrg)
                        if frontendDataOrg["tuner_type"] == "DVB-S":
-                               return (("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
+                               return (("NIM", ('A', 'B', 'C', 'D')[frontendData["tuner_number"]], TYPE_TEXT),
                                                        ("Type", frontendData["system"], TYPE_TEXT),
                                                        ("Modulation", frontendData["modulation"], TYPE_TEXT),
                                                        ("Orbital position", frontendData["orbital_position"], TYPE_VALUE_DEC),
@@ -198,7 +194,7 @@ class ServiceInfo(Screen):
                                                        ("Pilot", frontendData.get("pilot", None), TYPE_TEXT),
                                                        ("Rolloff", frontendData.get("rolloff", None), TYPE_TEXT))
                        elif frontendDataOrg["tuner_type"] == "DVB-C":
-                               return (("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
+                               return (("NIM", ('A', 'B', 'C', 'D')[frontendData["tuner_number"]], TYPE_TEXT),
                                                ("Type", frontendData["tuner_type"], TYPE_TEXT),
                                                ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
                                                ("Symbolrate", frontendData["symbol_rate"], TYPE_VALUE_DEC),
@@ -206,7 +202,7 @@ class ServiceInfo(Screen):
                                                ("Inversion", frontendData["inversion"], TYPE_TEXT),
                                                ("FEC inner", frontendData["fec_inner"], TYPE_TEXT))
                        elif frontendDataOrg["tuner_type"] == "DVB-T":
-                               return (("NIM", ['A', 'B', 'C', 'D'][frontendData["tuner_number"]], TYPE_TEXT),
+                               return (("NIM", ('A', 'B', 'C', 'D')[frontendData["tuner_number"]], TYPE_TEXT),
                                                ("Type", frontendData["tuner_type"], TYPE_TEXT),
                                                ("Frequency", frontendData["frequency"], TYPE_VALUE_DEC),
                                                ("Inversion", frontendData["inversion"], TYPE_TEXT),
index 1d035b8..7226562 100644 (file)
@@ -21,10 +21,10 @@ setupfile.close()
 
 class SetupError(Exception):
     def __init__(self, message):
-        self.message = message
+        self.msg = message
 
     def __str__(self):
-        return self.message
+        return self.msg
 
 class SetupSummary(Screen):
        skin = """
@@ -35,11 +35,10 @@ class SetupSummary(Screen):
        </screen>"""
 
        def __init__(self, session, parent):
-               Screen.__init__(self, session)
+               Screen.__init__(self, session, parent = parent)
                self["SetupTitle"] = Label(_(parent.setup_title))
                self["SetupEntry"] = Label("")
                self["SetupValue"] = Label("")
-               self.parent = parent
                self.onShow.append(self.addWatcher)
                self.onHide.append(self.removeWatcher)
                
index d09f28a..afea94b 100644 (file)
@@ -87,9 +87,6 @@ class StandbySummary(Screen):
                </widget>
        </screen>"""
 
-       def __init__(self, session, parent):
-               Screen.__init__(self, session)
-
 from enigma import quitMainloop, iRecordableService
 from Screens.MessageBox import MessageBox
 from time import time
@@ -100,7 +97,7 @@ inTryQuitMainloop = False
 class TryQuitMainloop(MessageBox):
        def __init__(self, session, retvalue=1, timeout=-1, default_yes = True):
                self.retval=retvalue
-               recordings = len(session.nav.getRecordings())
+               recordings = session.nav.getRecordings()
                jobs = len(job_manager.getPendingJobs())
                self.connected = False
                reason = ""
@@ -137,7 +134,7 @@ class TryQuitMainloop(MessageBox):
        def getRecordEvent(self, recservice, event):
                if event == iRecordableService.evEnd:
                        recordings = self.session.nav.getRecordings()
-                       if not len(recordings): # no more recordings exist
+                       if not recordings: # no more recordings exist
                                rec_time = self.session.nav.RecordTimer.getNextRecordingTime()
                                if rec_time > 0 and (rec_time - time()) < 360:
                                        self.initTimeout(360) # wait for next starting timer
index 24af517..3bcc3c4 100644 (file)
@@ -9,10 +9,17 @@ from Components.ServiceEventTracker import InfoBarBase
 
 from enigma import eTimer
 
-class SubservicesQuickzap(InfoBarBase, InfoBarShowHide, InfoBarMenu, InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport, InfoBarAudioSelection, Screen):
+class SubservicesQuickzap(InfoBarBase, InfoBarShowHide, InfoBarMenu, \
+               InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, \
+               InfoBarTimeshiftState, InfoBarExtensions, InfoBarSubtitleSupport, \
+               InfoBarAudioSelection, Screen):
+
        def __init__(self, session, subservices):
                Screen.__init__(self, session)
-               for x in [InfoBarBase, InfoBarShowHide, InfoBarMenu, InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, InfoBarTimeshiftState, InfoBarSubtitleSupport, InfoBarExtensions, InfoBarAudioSelection]:
+               for x in InfoBarBase, InfoBarShowHide, InfoBarMenu, \
+                               InfoBarInstantRecord, InfoBarSeek, InfoBarTimeshift, \
+                               InfoBarTimeshiftState, InfoBarSubtitleSupport, \
+                               InfoBarExtensions, InfoBarAudioSelection:
                        x.__init__(self)
 
                self.restoreService = self.session.nav.getCurrentlyPlayingServiceReference()
@@ -97,12 +104,15 @@ class SubservicesQuickzap(InfoBarBase, InfoBarShowHide, InfoBarMenu, InfoBarInst
        def showSelection(self):
                self.updateSubservices()
                tlist = []
-               if self.n is not None:
-                       for x in range(self.n):
-                               i = self.subservices.getSubservice(x)
-                               tlist.append((i.getName(), x))
+               n = self.n or 0
+               if n:
+                       idx = 0
+                       while idx < n:
+                               i = self.subservices.getSubservice(idx)
+                               tlist.append((i.getName(), idx))
+                               idx += 1
 
-               keys = [ "", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * self.n
+               keys = [ "", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * n
                self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice..."), list = tlist, selection = self.currentlyPlayingSubservice, keys = keys)
        
        def subserviceSelected(self, service):
index 80d3bd2..13ece59 100644 (file)
@@ -1,7 +1,6 @@
 from Screens.Screen import Screen
 
 class SubtitleDisplay(Screen):
-       def __init__(self, session):
-               Screen.__init__(self, session)
-               
+       pass
+
        # not really much to do...
index e637861..54bc7a5 100644 (file)
@@ -30,10 +30,11 @@ class Subtitles(Screen, ConfigListScreen):
                self.__selected_subtitle = None
 
        def fillList(self):
-               del self.list[:]
-               print "self.list", self.list
+               list = self.list
+               del list[:]
+               print "self.list", list
                if self.subtitlesEnabled():
-                       self.list.append(getConfigListEntry(_("Disable Subtitles"), ConfigNothing(), None))
+                       list.append(getConfigListEntry(_("Disable Subtitles"), ConfigNothing(), None))
                        sel = self.infobar.selected_subtitle
                else:
                        sel = None
@@ -44,29 +45,29 @@ class Subtitles(Screen, ConfigListScreen):
                                text = _("Enable")
                        if x[0] == 0:
                                if LanguageCodes.has_key(x[4]):
-                                       self.list.append(getConfigListEntry(text+" DVB "+LanguageCodes[x[4]][0], ConfigNothing(), x))
+                                       list.append(getConfigListEntry(text+" DVB "+LanguageCodes[x[4]][0], ConfigNothing(), x))
                                else:
-                                       self.list.append(getConfigListEntry(text+" DVB "+x[4], ConfigNothing(), x))
+                                       list.append(getConfigListEntry(text+" DVB "+x[4], ConfigNothing(), x))
                        elif x[0] == 1:
                                if x[4] == 'und': #undefined
-                                       self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2]), ConfigNothing(), x))
+                                       list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2]), ConfigNothing(), x))
                                else:
                                        if LanguageCodes.has_key(x[4]):
-                                               self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2])+" "+LanguageCodes[x[4]][0], ConfigNothing(), x))
+                                               list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2])+" "+LanguageCodes[x[4]][0], ConfigNothing(), x))
                                        else:
-                                               self.list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2])+" "+x[4], ConfigNothing(), x))
+                                               list.append(getConfigListEntry(text+" TTX "+_("Page")+" %x%02x"%(x[3],x[2])+" "+x[4], ConfigNothing(), x))
                        elif x[0] == 2:
-                               types = [" UTF-8 text "," SSA / AAS "," .SRT file "]
+                               types = (" UTF-8 text "," SSA / AAS "," .SRT file ")
                                if x[4] == 'und': #undefined
-                                       self.list.append(getConfigListEntry(text+types[x[2]]+_("Subtitles")+" %d" % x[1], ConfigNothing(), x))
+                                       list.append(getConfigListEntry(text+types[x[2]]+_("Subtitles")+" %d" % x[1], ConfigNothing(), x))
                                else:
                                        if LanguageCodes.has_key(x[4]):
-                                               self.list.append(getConfigListEntry(text+types[x[2]]+_("Subtitles") + ' ' + LanguageCodes[x[4]][0], ConfigNothing(), x))
+                                               list.append(getConfigListEntry(text+types[x[2]]+_("Subtitles") + ' ' + LanguageCodes[x[4]][0], ConfigNothing(), x))
                                        else:
-                                               self.list.append(getConfigListEntry(text+types[x[2]]+_("Subtitles")+" %d " % x[1] +x[4], ConfigNothing(), x))
+                                               list.append(getConfigListEntry(text+types[x[2]]+_("Subtitles")+" %d " % x[1] +x[4], ConfigNothing(), x))
 #              return _("Disable subtitles")
-               self["config"].list = self.list
-               self["config"].l.setList(self.list)
+               self["config"].list = list
+               self["config"].l.setList(list)
 
        def __updatedInfo(self):
                self.fillList()
@@ -95,7 +96,7 @@ class Subtitles(Screen, ConfigListScreen):
                ConfigListScreen.keyRight(self)
 
        def ok(self):
-               if len(self.list):
+               if self.list:
                        cur = self["config"].getCurrent()
                        self.enableSubtitle(cur[2])
                self.close(1)
index 6960427..1453c05 100644 (file)
@@ -80,7 +80,7 @@ class JobView(InfoBarNotifications, Screen, ConfigListScreen):
                else:
                        self["job_task"].text = ""
                        self["summary_job_task"].text = j.getStatustext()
-               if j.status in [j.FINISHED, j.FAILED]:
+               if j.status in (j.FINISHED, j.FAILED):
                        self.performAfterEvent()
                        self["backgroundable"].boolean = False
                        if j.status == j.FINISHED:
@@ -94,11 +94,11 @@ class JobView(InfoBarNotifications, Screen, ConfigListScreen):
                        self.close(True)
 
        def ok(self):
-               if self.job.status in [self.job.FINISHED, self.job.FAILED]:
+               if self.job.status in (self.job.FINISHED, self.job.FAILED):
                        self.close(False)
 
        def abort(self):
-               if self.job.status in [self.job.FINISHED, self.job.FAILED]:
+               if self.job.status in (self.job.FINISHED, self.job.FAILED):
                        self.close(False)
                if self["cancelable"].boolean == True:
                        self.job.cancel()
index 7f94090..56ccae9 100644 (file)
@@ -42,9 +42,10 @@ class TimeDateInput(Screen, ConfigListScreen):
                self.timeinput_time = conf_time
 
        def createSetup(self, configlist):
-               self.list = []
-               self.list.append(getConfigListEntry(_("Date"), self.timeinput_date))
-               self.list.append(getConfigListEntry(_("Time"), self.timeinput_time))
+               self.list = [
+                       getConfigListEntry(_("Date"), self.timeinput_date),
+                       getConfigListEntry(_("Time"), self.timeinput_time)
+               ]
                configlist.list = self.list
                configlist.l.setList(self.list)
 
index 6499ef5..caaf8c9 100644 (file)
@@ -171,14 +171,11 @@ class TimerEditList(Screen):
                        self.key_blue_choice = self.EMPTY
 
        def fillTimerList(self):
-               del self.list[:]
-               
-               for timer in self.session.nav.RecordTimer.timer_list:
-                       self.list.append((timer, False))
-               
-               for timer in self.session.nav.RecordTimer.processed_timers:
-                       self.list.append((timer, True))
-               self.list.sort(cmp = lambda x, y: x[0].begin < y[0].begin)
+               list = self.list
+               del list[:]
+               list.extend([(timer, False) for timer in self.session.nav.RecordTimer.timer_list])
+               list.extend([(timer, True) for timer in self.session.nav.RecordTimer.processed_timers])
+               list.sort(cmp = lambda x, y: x[0].begin < y[0].begin)
 
        def showLog(self):
                cur=self["timerlist"].getCurrent()
index 92a16af..73b2175 100644 (file)
@@ -57,12 +57,12 @@ class TimerEntry(Screen, ConfigListScreen):
                                AFTEREVENT.AUTO: "auto"
                                }[self.timer.afterEvent]
 
-                       weekday_table = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"]
+                       weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun")
 
                        # calculate default values
                        day = []
                        weekday = 0
-                       for x in range(0,7):
+                       for x in (0, 1, 2, 3, 4, 5, 6):
                                day.append(0)
                        if self.timer.repeated: # repeated
                                type = "repeated"
@@ -74,7 +74,7 @@ class TimerEntry(Screen, ConfigListScreen):
                                        flags = self.timer.repeated
                                        repeated = "user"
                                        count = 0
-                                       for x in range(0, 7):
+                                       for x in (0, 1, 2, 3, 4, 5, 6):
                                                if flags == 1: # weekly
                                                        print "Set to weekday " + str(x)
                                                        weekday = x
@@ -98,7 +98,7 @@ class TimerEntry(Screen, ConfigListScreen):
                        self.timerentry_name = ConfigText(default = self.timer.name, visible_width = 50, fixed_size = False)
                        self.timerentry_description = ConfigText(default = self.timer.description, visible_width = 50, fixed_size = False)
                        self.timerentry_tags = self.timer.tags[:]
-                       self.timerentry_tagsset = ConfigSelection(choices = [len(self.timerentry_tags) == 0 and "None" or " ".join(self.timerentry_tags)])
+                       self.timerentry_tagsset = ConfigSelection(choices = [not self.timerentry_tags and "None" or " ".join(self.timerentry_tags)])
 
                        self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))])
 
@@ -117,7 +117,7 @@ class TimerEntry(Screen, ConfigListScreen):
                        self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))])
 
                        self.timerentry_day = ConfigSubList()
-                       for x in range(0,7):
+                       for x in (0, 1, 2, 3, 4, 5, 6):
                                self.timerentry_day.append(ConfigYesNo(default = day[x]))
 
                        # FIXME some service-chooser needed here
@@ -197,14 +197,14 @@ class TimerEntry(Screen, ConfigListScreen):
                        self.createSetup("config")
 
        def keyLeft(self):
-               if self["config"].getCurrent() in [self.channelEntry, self.tagsSet]:
+               if self["config"].getCurrent() in (self.channelEntry, self.tagsSet):
                        self.keySelect()
                else:
                        ConfigListScreen.keyLeft(self)
                        self.newConfig()
 
        def keyRight(self):
-               if self["config"].getCurrent() in [self.channelEntry, self.tagsSet]:
+               if self["config"].getCurrent() in (self.channelEntry, self.tagsSet):
                        self.keySelect()
                else:
                        ConfigListScreen.keyRight(self)
@@ -236,7 +236,7 @@ class TimerEntry(Screen, ConfigListScreen):
                        self.keyGo()
 
        def finishedChannelSelection(self, *args):
-               if len(args):
+               if args:
                        self.timerentry_service_ref = ServiceReference(args[0])
                        self.timerentry_service.setCurrentText(self.timerentry_service_ref.getServiceName())
                        self["config"].invalidate(self.channelEntry)
@@ -281,18 +281,18 @@ class TimerEntry(Screen, ConfigListScreen):
                        self.timer.begin, self.timer.end = self.getBeginEnd()
                if self.timerentry_type.value == "repeated":
                        if self.timerentry_repeated.value == "daily":
-                               for x in range(0,7):
+                               for x in (0, 1, 2, 3, 4, 5, 6):
                                        self.timer.setRepeated(x)
 
                        if self.timerentry_repeated.value == "weekly":
                                self.timer.setRepeated(self.timerentry_weekday.index)
 
                        if self.timerentry_repeated.value == "weekdays":
-                               for x in range(0,5):
+                               for x in (0, 1, 2, 3, 4):
                                        self.timer.setRepeated(x)
 
                        if self.timerentry_repeated.value == "user":
-                               for x in range(0,7):
+                               for x in (0, 1, 2, 3, 4, 5, 6):
                                        if self.timerentry_day[x].value:
                                                self.timer.setRepeated(x)
 
@@ -367,7 +367,7 @@ class TimerEntry(Screen, ConfigListScreen):
        def tagEditFinished(self, ret):
                if ret is not None:
                        self.timerentry_tags = ret
-                       self.timerentry_tagsset.setChoices([len(ret) == 0 and "None" or " ".join(ret)])
+                       self.timerentry_tagsset.setChoices([not ret and "None" or " ".join(ret)])
                        self["config"].invalidate(self.tagsSet)
 
 class TimerLog(Screen):
@@ -410,9 +410,7 @@ class TimerLog(Screen):
                self.updateText()
 
        def fillLogList(self):
-               self.list = [ ]
-               for x in self.log_entries:
-                       self.list.append((str(strftime("%Y-%m-%d %H-%M", localtime(x[0])) + " - " + x[2]), x))
+               self.list = [(str(strftime("%Y-%m-%d %H-%M", localtime(x[0])) + " - " + x[2]), x) for x in self.log_entries]
 
        def clearLog(self):
                self.log_entries = []
@@ -444,7 +442,7 @@ class TimerLog(Screen):
                self.updateText()
 
        def updateText(self):
-               if len(self.list) > 0:
+               if self.list:
                        self["logentry"].setText(str(self["loglist"].getCurrent()[1][2]))
                else:
                        self["logentry"].setText("")
index 7a1d9ec..a97c7ba 100644 (file)
@@ -22,4 +22,3 @@ class TimerSelection(Screen):
        
        def selected(self):
                self.close(self["timerlist"].getCurrentIndex())
-       
\ No newline at end of file
index 5dc1a09..9b676a5 100755 (executable)
-# -*- coding: iso-8859-1 -*-\r
-from Components.Language import language\r
-from Components.ActionMap import ActionMap\r
-from Components.Label import Label\r
-from Components.Pixmap import Pixmap\r
-from Components.MenuList import MenuList\r
-from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest\r
-from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_CENTER, RT_VALIGN_CENTER\r
-from Screen import Screen\r
-from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE\r
-from Tools.LoadPixmap import LoadPixmap\r
-\r
-class VirtualKeyBoardList(MenuList):\r
-       def __init__(self, list, enableWrapAround=False):\r
-               MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)\r
-               self.l.setFont(0, gFont("Regular", 22))\r
-               self.l.setItemHeight(45)\r
-\r
-def VirtualKeyBoardEntryComponent(keys, selectedKey,shiftMode=False):\r
-       key_backspace = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_backspace.png"))\r
-       key_bg = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_bg.png"))\r
-       key_clr = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_clr.png"))\r
-       key_esc = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_esc.png"))\r
-       key_ok = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_ok.png"))\r
-       key_sel = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_sel.png"))\r
-       key_shift = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_shift.png"))\r
-       key_shift_sel = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_shift_sel.png"))\r
-       key_space = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_space.png"))\r
-       \r
-       res = [ (keys) ]\r
-       \r
-       x = 0\r
-       count = 0\r
-       if shiftMode:\r
-               shiftkey_png = key_shift_sel\r
-       else:\r
-               shiftkey_png = key_shift\r
-       for key in keys:\r
-               if key == "EXIT":\r
-                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_esc))\r
-               elif key == "BACKSPACE":\r
-                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_backspace))\r
-               elif key == "CLEAR":\r
-                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_clr))\r
-               elif key == "SHIFT":\r
-                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=shiftkey_png))\r
-               elif key == "SPACE":\r
-                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_space))\r
-               elif key == "OK":\r
-                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_ok))\r
-               #elif key == "<-":\r
-               #       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_left))\r
-               #elif key == "->":\r
-               #       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_right))\r
-               \r
-               else:\r
-                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_bg))\r
-                       res.append(MultiContentEntryText(pos=(x, 0), size=(45, 45), font=0, text=key.encode("utf-8"), flags=RT_HALIGN_CENTER | RT_VALIGN_CENTER))\r
-               \r
-               if selectedKey == count:\r
-                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_sel))\r
-               \r
-               x += 45\r
-               count += 1\r
-       \r
-       return res\r
-\r
-\r
-class VirtualKeyBoard(Screen):\r
-\r
-       def __init__(self, session, title="", text=""):\r
-               Screen.__init__(self, session)\r
-               self.keys_list = []\r
-               self.shiftkeys_list = []\r
-               self.lang = language.getLanguage()\r
-               if self.lang == 'de_DE':\r
-                       self.keys_list = [\r
-                               [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],\r
-                               [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"ü", u"+"],\r
-                               [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ö", u"ä", u"#"],\r
-                               [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"],\r
-                               [u"SHIFT", u"SPACE", u"@", u"ß", u"OK"]]\r
-                       \r
-                       self.shiftkeys_list = [\r
-                               [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],\r
-                               [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"Ü", u"*"],\r
-                               [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ö", u"Ä", u"'"],\r
-                               [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],\r
-                               [u"SHIFT", u"SPACE", u"?", u"\\", u"OK"]]\r
-                       \r
-               elif self.lang == 'es_ES':\r
-                       #still missing keys (u"ùÙ")\r
-                       self.keys_list = [\r
-                               [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],\r
-                               [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"ú", u"+"],\r
-                               [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ó", u"á", u"#"],\r
-                               [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"],\r
-                               [u"SHIFT", u"SPACE", u"@", u"£", u"à", u"é", u"è", u"í", u"ì", u"ñ", u"ò", u"OK"]]\r
-                       \r
-                       self.shiftkeys_list = [\r
-                               [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],\r
-                               [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"Ú", u"*"],\r
-                               [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ó", u"Á", u"'"],\r
-                               [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],\r
-                               [u"SHIFT", u"SPACE", u"?", u"\\", u"À", u"É", u"È",  u"Í", u"Ì", u"Ñ", u"Ò", u"OK"]]\r
-                               \r
-               elif self.lang in ['sv_SE', 'fi_FI']:\r
-                       self.keys_list = [\r
-                               [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],\r
-                               [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"é", u"+"],\r
-                               [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ö", u"ä", u"#"],\r
-                               [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"],\r
-                               [u"SHIFT", u"SPACE", u"@", u"ß", u"å", u"OK"]]\r
-                               \r
-                       self.shiftkeys_list = [\r
-                               [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],\r
-                               [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"É", u"*"],\r
-                               [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ö", u"Ä", u"'"],\r
-                               [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],\r
-\r
-                               [u"SHIFT", u"SPACE", u"?", u"\\", u"Å", u"OK"]]\r
-               else:\r
-                       self.keys_list = [\r
-                               [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],\r
-                               [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"+", u"@"],\r
-                               [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"#", u"\\"],\r
-                               [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"],\r
-                               [u"SHIFT", u"SPACE", u"OK"]]\r
-                       \r
-                       self.shiftkeys_list = [\r
-                               [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],\r
-                               [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"*"],\r
-                               [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"'", u"?"],\r
-                               [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],\r
-                               [u"SHIFT", u"SPACE", u"OK"]]\r
-               \r
-               self.shiftMode = False\r
-               self.text = text\r
-               self.selectedKey = 0\r
-               \r
-               self["header"] = Label(title)\r
-               self["text"] = Label(self.text)\r
-               self["list"] = VirtualKeyBoardList([])\r
-               \r
-               self["actions"] = ActionMap(["OkCancelActions", "WizardActions", "ColorActions"],\r
-                       {\r
-                               "ok": self.okClicked,\r
-                               "cancel": self.exit,\r
-                               "left": self.left,\r
-                               "right": self.right,\r
-                               "up": self.up,\r
-                               "down": self.down,\r
-                               "red": self.backClicked,\r
-                               "green": self.ok\r
-                       }, -2)\r
-               \r
-               self.onLayoutFinish.append(self.buildVirtualKeyBoard)\r
-\r
-       def buildVirtualKeyBoard(self, selectedKey=0):\r
-               list = []\r
-               \r
-               if self.shiftMode:\r
-                       self.k_list = self.shiftkeys_list\r
-                       for keys in self.k_list:\r
-                               if selectedKey < 12 and selectedKey > -1:\r
-                                       list.append(VirtualKeyBoardEntryComponent(keys, selectedKey,True))\r
-                               else:\r
-                                       list.append(VirtualKeyBoardEntryComponent(keys, -1,True))\r
-                               selectedKey -= 12\r
-               else:\r
-                       self.k_list = self.keys_list\r
-                       for keys in self.k_list:\r
-                               if selectedKey < 12 and selectedKey > -1:\r
-                                       list.append(VirtualKeyBoardEntryComponent(keys, selectedKey))\r
-                               else:\r
-                                       list.append(VirtualKeyBoardEntryComponent(keys, -1))\r
-                               selectedKey -= 12\r
-               \r
-               self["list"].setList(list)\r
-\r
-       \r
-       def backClicked(self):\r
-               self.text = self["text"].getText()[:-1]\r
-               self["text"].setText(self.text)\r
-                       \r
-       def okClicked(self):\r
-               if self.shiftMode:\r
-                       list = self.shiftkeys_list\r
-               else:\r
-                       list = self.keys_list\r
-               \r
-               selectedKey = self.selectedKey\r
-\r
-               for x in list:\r
-                       if selectedKey < 12:\r
-                               text = x[selectedKey]\r
-                               break\r
-                       else:\r
-                               selectedKey -= 12\r
-\r
-               text = text.encode("utf-8")\r
-\r
-               if text == "EXIT":\r
-                       self.close(None)\r
-               \r
-               elif text == "BACKSPACE":\r
-                       self.text = self["text"].getText()[:-1]\r
-                       self["text"].setText(self.text)\r
-               \r
-               elif text == "CLEAR":\r
-                       self.text = ""\r
-                       self["text"].setText(self.text)\r
-               \r
-               elif text == "SHIFT":\r
-                       if self.shiftMode:\r
-                               self.shiftMode = False\r
-                       else:\r
-                               self.shiftMode = True\r
-                       \r
-                       self.buildVirtualKeyBoard(self.selectedKey)\r
-               \r
-               elif text == "SPACE":\r
-                       self.text += " "\r
-                       self["text"].setText(self.text)\r
-               \r
-               elif text == "OK":\r
-                       self.close(self["text"].getText())\r
-               \r
-               else:\r
-                       self.text = self["text"].getText()\r
-                       self.text += text\r
-                       self["text"].setText(self.text)\r
-\r
-       def ok(self):\r
-               self.close(self["text"].getText())\r
-\r
-       def exit(self):\r
-               self.close(None)\r
-\r
-       def left(self):\r
-               self.selectedKey -= 1\r
-               \r
-               if self.selectedKey == -1:\r
-                       self.selectedKey = 11\r
-               elif self.selectedKey == 11:\r
-                       self.selectedKey = 23\r
-               elif self.selectedKey == 23:\r
-                       self.selectedKey = 35\r
-               elif self.selectedKey == 35:\r
-                       self.selectedKey = 47\r
-               elif self.selectedKey == 47:\r
-                       self.selectedKey = 59\r
-               \r
-               self.showActiveKey()\r
-\r
-       def right(self):\r
-               self.selectedKey += 1\r
-               \r
-               if self.selectedKey == 12:\r
-                       self.selectedKey = 0\r
-               elif self.selectedKey == 24:\r
-                       self.selectedKey = 12\r
-               elif self.selectedKey == 36:\r
-                       self.selectedKey = 24\r
-               elif self.selectedKey == 48:\r
-                       self.selectedKey = 36\r
-               elif self.selectedKey == 60:\r
-                       self.selectedKey = 48\r
-               \r
-               self.showActiveKey()\r
-\r
-       def up(self):\r
-               self.selectedKey -= 12\r
-               \r
-               if self.selectedKey < 0:\r
-                       self.selectedKey += 60\r
-               \r
-               self.showActiveKey()\r
-\r
-       def down(self):\r
-               self.selectedKey += 12\r
-               \r
-               if self.selectedKey > 59:\r
-                       self.selectedKey -= 60\r
-               \r
-               self.showActiveKey()\r
-\r
-       def showActiveKey(self):\r
-               self.buildVirtualKeyBoard(self.selectedKey)\r
+# -*- coding: iso-8859-1 -*-
+from Components.Language import language
+from Components.ActionMap import ActionMap
+from Components.Label import Label
+from Components.Pixmap import Pixmap
+from Components.MenuList import MenuList
+from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest
+from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_CENTER, RT_VALIGN_CENTER
+from Screen import Screen
+from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
+from Tools.LoadPixmap import LoadPixmap
+
+class VirtualKeyBoardList(MenuList):
+       def __init__(self, list, enableWrapAround=False):
+               MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
+               self.l.setFont(0, gFont("Regular", 22))
+               self.l.setItemHeight(45)
+
+def VirtualKeyBoardEntryComponent(keys, selectedKey,shiftMode=False):
+       key_backspace = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_backspace.png"))
+       key_bg = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_bg.png"))
+       key_clr = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_clr.png"))
+       key_esc = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_esc.png"))
+       key_ok = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_ok.png"))
+       key_sel = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_sel.png"))
+       key_shift = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_shift.png"))
+       key_shift_sel = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_shift_sel.png"))
+       key_space = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_space.png"))
+       
+       res = [ (keys) ]
+       
+       x = 0
+       count = 0
+       if shiftMode:
+               shiftkey_png = key_shift_sel
+       else:
+               shiftkey_png = key_shift
+       for key in keys:
+               if key == "EXIT":
+                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_esc))
+               elif key == "BACKSPACE":
+                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_backspace))
+               elif key == "CLEAR":
+                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_clr))
+               elif key == "SHIFT":
+                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=shiftkey_png))
+               elif key == "SPACE":
+                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_space))
+               elif key == "OK":
+                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_ok))
+               #elif key == "<-":
+               #       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_left))
+               #elif key == "->":
+               #       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_right))
+               
+               else:
+                       res.extend((
+                               MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_bg),
+                               MultiContentEntryText(pos=(x, 0), size=(45, 45), font=0, text=key.encode("utf-8"), flags=RT_HALIGN_CENTER | RT_VALIGN_CENTER)
+                       ))
+               
+               if selectedKey == count:
+                       res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_sel))
+               
+               x += 45
+               count += 1
+       
+       return res
+
+
+class VirtualKeyBoard(Screen):
+
+       def __init__(self, session, title="", text=""):
+               Screen.__init__(self, session)
+               self.keys_list = []
+               self.shiftkeys_list = []
+               self.lang = language.getLanguage()
+               if self.lang == 'de_DE':
+                       self.keys_list = [
+                               [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
+                               [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"ü", u"+"],
+                               [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ö", u"ä", u"#"],
+                               [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"],
+                               [u"SHIFT", u"SPACE", u"@", u"ß", u"OK"]]
+                       
+                       self.shiftkeys_list = [
+                               [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],
+                               [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"Ü", u"*"],
+                               [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ö", u"Ä", u"'"],
+                               [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],
+                               [u"SHIFT", u"SPACE", u"?", u"\\", u"OK"]]
+                       
+               elif self.lang == 'es_ES':
+                       #still missing keys (u"ùÙ")
+                       self.keys_list = [
+                               [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
+                               [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"ú", u"+"],
+                               [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ó", u"á", u"#"],
+                               [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"],
+                               [u"SHIFT", u"SPACE", u"@", u"£", u"à", u"é", u"è", u"í", u"ì", u"ñ", u"ò", u"OK"]]
+                       
+                       self.shiftkeys_list = [
+                               [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],
+                               [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"Ú", u"*"],
+                               [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ó", u"Á", u"'"],
+                               [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],
+                               [u"SHIFT", u"SPACE", u"?", u"\\", u"À", u"É", u"È",  u"Í", u"Ì", u"Ñ", u"Ò", u"OK"]]
+                               
+               elif self.lang in ('sv_SE', 'fi_FI'):
+                       self.keys_list = [
+                               [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
+                               [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"é", u"+"],
+                               [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ö", u"ä", u"#"],
+                               [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"],
+                               [u"SHIFT", u"SPACE", u"@", u"ß", u"å", u"OK"]]
+                               
+                       self.shiftkeys_list = [
+                               [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],
+                               [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"É", u"*"],
+                               [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ö", u"Ä", u"'"],
+                               [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],
+
+                               [u"SHIFT", u"SPACE", u"?", u"\\", u"Å", u"OK"]]
+               else:
+                       self.keys_list = [
+                               [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
+                               [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"+", u"@"],
+                               [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"#", u"\\"],
+                               [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"],
+                               [u"SHIFT", u"SPACE", u"OK"]]
+                       
+                       self.shiftkeys_list = [
+                               [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],
+                               [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"*"],
+                               [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"'", u"?"],
+                               [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],
+                               [u"SHIFT", u"SPACE", u"OK"]]
+               
+               self.shiftMode = False
+               self.text = text
+               self.selectedKey = 0
+               
+               self["header"] = Label(title)
+               self["text"] = Label(self.text)
+               self["list"] = VirtualKeyBoardList([])
+               
+               self["actions"] = ActionMap(["OkCancelActions", "WizardActions", "ColorActions"],
+                       {
+                               "ok": self.okClicked,
+                               "cancel": self.exit,
+                               "left": self.left,
+                               "right": self.right,
+                               "up": self.up,
+                               "down": self.down,
+                               "red": self.backClicked,
+                               "green": self.ok
+                       }, -2)
+               
+               self.onLayoutFinish.append(self.buildVirtualKeyBoard)
+
+       def buildVirtualKeyBoard(self, selectedKey=0):
+               list = []
+               
+               if self.shiftMode:
+                       self.k_list = self.shiftkeys_list
+                       for keys in self.k_list:
+                               if selectedKey < 12 and selectedKey > -1:
+                                       list.append(VirtualKeyBoardEntryComponent(keys, selectedKey,True))
+                               else:
+                                       list.append(VirtualKeyBoardEntryComponent(keys, -1,True))
+                               selectedKey -= 12
+               else:
+                       self.k_list = self.keys_list
+                       for keys in self.k_list:
+                               if selectedKey < 12 and selectedKey > -1:
+                                       list.append(VirtualKeyBoardEntryComponent(keys, selectedKey))
+                               else:
+                                       list.append(VirtualKeyBoardEntryComponent(keys, -1))
+                               selectedKey -= 12
+               
+               self["list"].setList(list)
+
+       
+       def backClicked(self):
+               self.text = self["text"].getText()[:-1]
+               self["text"].setText(self.text)
+                       
+       def okClicked(self):
+               if self.shiftMode:
+                       list = self.shiftkeys_list
+               else:
+                       list = self.keys_list
+               
+               selectedKey = self.selectedKey
+
+               for x in list:
+                       if selectedKey < 12:
+                               text = x[selectedKey]
+                               break
+                       else:
+                               selectedKey -= 12
+
+               text = text.encode("utf-8")
+
+               if text == "EXIT":
+                       self.close(None)
+               
+               elif text == "BACKSPACE":
+                       self.text = self["text"].getText()[:-1]
+                       self["text"].setText(self.text)
+               
+               elif text == "CLEAR":
+                       self.text = ""
+                       self["text"].setText(self.text)
+               
+               elif text == "SHIFT":
+                       if self.shiftMode:
+                               self.shiftMode = False
+                       else:
+                               self.shiftMode = True
+                       
+                       self.buildVirtualKeyBoard(self.selectedKey)
+               
+               elif text == "SPACE":
+                       self.text += " "
+                       self["text"].setText(self.text)
+               
+               elif text == "OK":
+                       self.close(self["text"].getText())
+               
+               else:
+                       self.text = self["text"].getText()
+                       self.text += text
+                       self["text"].setText(self.text)
+
+       def ok(self):
+               self.close(self["text"].getText())
+
+       def exit(self):
+               self.close(None)
+
+       def left(self):
+               self.selectedKey -= 1
+               
+               if self.selectedKey == -1:
+                       self.selectedKey = 11
+               elif self.selectedKey == 11:
+                       self.selectedKey = 23
+               elif self.selectedKey == 23:
+                       self.selectedKey = 35
+               elif self.selectedKey == 35:
+                       self.selectedKey = 47
+               elif self.selectedKey == 47:
+                       self.selectedKey = 59
+               
+               self.showActiveKey()
+
+       def right(self):
+               self.selectedKey += 1
+               
+               if self.selectedKey == 12:
+                       self.selectedKey = 0
+               elif self.selectedKey == 24:
+                       self.selectedKey = 12
+               elif self.selectedKey == 36:
+                       self.selectedKey = 24
+               elif self.selectedKey == 48:
+                       self.selectedKey = 36
+               elif self.selectedKey == 60:
+                       self.selectedKey = 48
+               
+               self.showActiveKey()
+
+       def up(self):
+               self.selectedKey -= 12
+               
+               if self.selectedKey < 0:
+                       self.selectedKey += 60
+               
+               self.showActiveKey()
+
+       def down(self):
+               self.selectedKey += 12
+               
+               if self.selectedKey > 59:
+                       self.selectedKey -= 60
+               
+               self.showActiveKey()
+
+       def showActiveKey(self):
+               self.buildVirtualKeyBoard(self.selectedKey)
index 7d454f4..555110a 100755 (executable)
@@ -604,10 +604,7 @@ class WizardManager:
                self.wizards.append((wizard, precondition, priority))
        
        def getWizards(self):
-               list = []
-               for x in self.wizards:
-                       if x[1] == 1: # precondition
-                               list.append((x[2], x[0]))
-               return list
+               # x[1] is precondition
+               return [(x[2], x[0]) for x in self.wizards if x[1] == 1]
 
 wizardManager = WizardManager()
index ec9758d..91fc80d 100644 (file)
@@ -31,7 +31,3 @@ class WizardLanguage(Wizard):
                self.updateText(firstset = True)
                self.updateValues()
                self.updateLanguageDescription()
-               
-
-               
-               
\ No newline at end of file
index c557640..df6a5ea 100644 (file)
@@ -52,7 +52,7 @@ class NumericalTextInput:
                        self.mapping.append (u"pqrs7PQRS") # 7
                        self.mapping.append (u"tuvúù8TUVÚÙ") # 8
                        self.mapping.append (u"wxyz9WXYZ") # 9
-               if self.lang in ['sv_SE', 'fi_FI']:
+               if self.lang in ('sv_SE', 'fi_FI'):
                        self.mapping.append (u".,?'+\"0-()@/:_$!") # 0
                        self.mapping.append (u" 1") # 1
                        self.mapping.append (u"abcåä2ABCÅÄ") # 2
index c335bf2..efbc34b 100755 (executable)
--- a/mytest.py
+++ b/mytest.py
@@ -256,7 +256,7 @@ class Session:
                        self.execEnd(last=False)
 
        def popCurrent(self):
-               if len(self.dialog_stack):
+               if self.dialog_stack:
                        (self.current_dialog, do_show) = self.dialog_stack.pop()
                        self.execBegin(first=False, do_show=do_show)
                else:
@@ -275,7 +275,7 @@ class Session:
                return dlg
 
        def open(self, screen, *arguments, **kwargs):
-               if len(self.dialog_stack) and not self.in_exec:
+               if self.dialog_stack and not self.in_exec:
                        raise RuntimeError("modal open are allowed only from a screen which is modal!")
                        # ...unless it's the very first screen.
 
@@ -417,10 +417,7 @@ def runScreenTest():
 
        CiHandler.setSession(session)
 
-       screensToRun = [ ]
-
-       for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD):
-               screensToRun.append(p.__call__)
+       screensToRun = [ p.__call__ for p in plugins.getPlugins(PluginDescriptor.WHERE_WIZARD) ]
 
        profile("wizards")
        screensToRun += wizardManager.getWizards()
@@ -444,7 +441,7 @@ def runScreenTest():
 
                screen = screensToRun[0][1]
 
-               if len(screensToRun):
+               if screensToRun:
                        session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
                else:
                        session.open(screen)
@@ -476,8 +473,8 @@ def runScreenTest():
        ]
        wakeupList.sort()
        recordTimerWakeupAuto = False
-       if len(wakeupList):
-               startTime = wakeupList.pop(0)
+       if wakeupList:
+               startTime = wakeupList[0]
                if (startTime[0] - nowTime) < 330: # no time to switch box back on
                        wptime = nowTime + 30  # so switch back on in 30 seconds
                else:
diff --git a/skin.py b/skin.py
index 6baf6b7..a37716f 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -26,10 +26,10 @@ def dump(x, i=0):
 
 class SkinError(Exception):
        def __init__(self, message):
-               self.message = message
+               self.msg = message
 
        def __str__(self):
-               return "{%s}: %s" % (config.skin.primary_skin, self.message)
+               return "{%s}: %s" % (config.skin.primary_skin, self.msg)
 
 dom_skins = [ ]
 
@@ -98,7 +98,7 @@ def collectAttributes(skinAttributes, node, skin_path_prefix=None, ignore=[]):
                attrib = a[0]
                value = a[1]
 
-               if attrib in ["pixmap", "pointer", "seek_pointer", "backgroundPixmap", "selectionPixmap"]:
+               if attrib in ("pixmap", "pointer", "seek_pointer", "backgroundPixmap", "selectionPixmap"):
                        value = resolveFilename(SCOPE_SKIN_IMAGE, value, path_prefix=skin_path_prefix)
 
                if attrib not in ignore:
@@ -131,7 +131,7 @@ def applySingleAttribute(guiObject, desktop, attrib, value, scale = ((1,1),(1,1)
                        guiObject.setFont(parseFont(value, scale))
                elif attrib == 'zPosition':
                        guiObject.setZPosition(int(value))
-               elif attrib in ["pixmap", "backgroundPixmap", "selectionPixmap"]:
+               elif attrib in ("pixmap", "backgroundPixmap", "selectionPixmap"):
                        ptr = loadPixmap(value, desktop) # this should already have been filename-resolved.
                        if attrib == "pixmap":
                                guiObject.setPixmap(ptr)
index fd5bb5a..64df9c8 100644 (file)
--- a/timer.py
+++ b/timer.py
@@ -222,7 +222,7 @@ class Timer:
                min = int(time()) + self.MaxWaitTime
                
                # calculate next activation point
-               if len(self.timer_list):
+               if self.timer_list:
                        w = self.timer_list[0].getNextActivation()
                        if w < min:
                                min = w
@@ -278,5 +278,5 @@ class Timer:
                t = int(time()) + 1
                
                # we keep on processing the first entry until it goes into the future.
-               while len(self.timer_list) and self.timer_list[0].getNextActivation() < t:
+               while self.timer_list and self.timer_list[0].getNextActivation() < t:
                        self.doActivate(self.timer_list[0])