From e180b709f892553d73784a30dc32e8251ad7b544 Mon Sep 17 00:00:00 2001 From: ghost Date: Fri, 20 Feb 2009 02:21:50 +0100 Subject: split "delay after continuous tone" value in "delay after continuous tone disable before diseqc" and "delay after final continuous tone change" value and increment the first value now to 25 to fix "tune failed" problems with some diseqc switches --- lib/python/Components/NimManager.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/python/Components/NimManager.py') diff --git a/lib/python/Components/NimManager.py b/lib/python/Components/NimManager.py index 6dc49dcf..75ad3779 100644 --- a/lib/python/Components/NimManager.py +++ b/lib/python/Components/NimManager.py @@ -835,9 +835,13 @@ class NimManager: def InitSecParams(): config.sec = ConfigSubsection() - x = ConfigInteger(default=15, limits = (0, 9999)) - x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE, configElement.value)) - config.sec.delay_after_continuous_tone_change = x + x = ConfigInteger(default=25, limits = (0, 9999)) + x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_CONT_TONE_DISABLE_BEFORE_DISEQC, configElement.value)) + config.sec.delay_after_continuous_tone_disable_before_diseqc = x + + x = ConfigInteger(default=10, limits = (0, 9999)) + x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_CONT_TONE_CHANGE, configElement.value)) + config.sec.delay_after_final_continuous_tone_change = x x = ConfigInteger(default=10, limits = (0, 9999)) x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_FINAL_VOLTAGE_CHANGE, configElement.value)) -- cgit v1.2.3 From 574f425cc1ebece0aa5f09fb77a8cb7ad0310a1f Mon Sep 17 00:00:00 2001 From: ghost Date: Tue, 24 Feb 2009 20:56:21 +0100 Subject: small optimizations and cleanups by Moritz Venn --- RecordTimer.py | 2 +- keymapparser.py | 4 +- lib/python/Components/Converter/FrontendInfo.py | 4 +- lib/python/Components/Converter/RdsInfo.py | 14 +- lib/python/Components/Converter/ServiceInfo.py | 36 +- lib/python/Components/Converter/ServiceName.py | 2 +- lib/python/Components/Converter/ServicePosition.py | 6 +- lib/python/Components/Converter/ServiceTime.py | 2 +- lib/python/Components/Converter/Streaming.py | 3 - lib/python/Components/DreamInfoHandler.py | 2 +- lib/python/Components/Element.py | 4 +- lib/python/Components/Harddisk.py | 15 +- lib/python/Components/HelpMenuList.py | 12 +- lib/python/Components/Language.py | 13 +- lib/python/Components/NimManager.py | 28 +- lib/python/Components/ParentalControl.py | 7 +- lib/python/Components/ParentalControlList.py | 6 +- lib/python/Components/PluginComponent.py | 6 +- lib/python/Components/PluginList.py | 40 +- lib/python/Components/Renderer/FrontpanelLed.py | 3 - lib/python/Components/Renderer/Picon.py | 4 +- lib/python/Components/Scanner.py | 5 +- lib/python/Components/SelectionList.py | 18 +- lib/python/Components/Sources/RdsDecoder.py | 2 +- lib/python/Components/TimerList.py | 2 +- lib/python/Components/TimerSanityCheck.py | 3 +- lib/python/Components/Timezones.py | 7 +- lib/python/Components/config.py | 6 +- .../Plugins/Extensions/CutListEditor/plugin.py | 6 +- .../Plugins/Extensions/DVDBurn/TitleProperties.py | 7 +- lib/python/Plugins/Extensions/DVDBurn/plugin.py | 5 +- lib/python/Plugins/Extensions/DVDPlayer/plugin.py | 2 +- .../Plugins/Extensions/FileManager/plugin.py | 5 +- .../Plugins/Extensions/MediaPlayer/plugin.py | 8 +- .../Plugins/Extensions/MediaScanner/plugin.py | 10 +- .../Plugins/Extensions/PicturePlayer/plugin.py | 2 +- lib/python/Plugins/Extensions/SocketMMI/plugin.py | 2 +- .../Plugins/SystemPlugins/DiseqcTester/plugin.py | 2 +- .../SystemPlugins/SoftwareManager/BackupRestore.py | 2 - .../SystemPlugins/Videomode/VideoHardware.py | 4 +- .../Plugins/SystemPlugins/Videomode/VideoWizard.py | 2 +- .../Plugins/SystemPlugins/Videomode/plugin.py | 13 +- lib/python/Screens/About.py | 4 +- lib/python/Screens/ChannelSelection.py | 40 +- lib/python/Screens/Ci.py | 2 +- lib/python/Screens/Console.py | 3 +- lib/python/Screens/DefaultWizard.py | 4 +- lib/python/Screens/EpgSelection.py | 2 +- lib/python/Screens/EventView.py | 16 +- lib/python/Screens/HarddiskSetup.py | 2 +- lib/python/Screens/HelpMenu.py | 16 +- lib/python/Screens/InfoBar.py | 4 +- lib/python/Screens/InfoBarGenerics.py | 83 ++- lib/python/Screens/LanguageSelection.py | 19 +- lib/python/Screens/LocationBox.py | 17 +- lib/python/Screens/Menu.py | 5 +- lib/python/Screens/MessageBox.py | 4 +- lib/python/Screens/MovieSelection.py | 18 +- lib/python/Screens/Mute.py | 3 +- lib/python/Screens/NetworkSetup.py | 23 +- lib/python/Screens/NumericalTextInputHelpDialog.py | 2 +- lib/python/Screens/PVRState.py | 4 +- lib/python/Screens/ParentalControlSetup.py | 4 +- lib/python/Screens/PluginBrowser.py | 18 +- lib/python/Screens/Rc.py | 1 - lib/python/Screens/Satconfig.py | 14 +- lib/python/Screens/ServiceInfo.py | 24 +- lib/python/Screens/Setup.py | 7 +- lib/python/Screens/Standby.py | 7 +- lib/python/Screens/SubservicesQuickzap.py | 24 +- lib/python/Screens/SubtitleDisplay.py | 5 +- lib/python/Screens/Subtitles.py | 31 +- lib/python/Screens/TaskView.py | 6 +- lib/python/Screens/TimeDateInput.py | 7 +- lib/python/Screens/TimerEdit.py | 13 +- lib/python/Screens/TimerEntry.py | 30 +- lib/python/Screens/TimerSelection.py | 1 - lib/python/Screens/VirtualKeyBoard.py | 580 +++++++++++---------- lib/python/Screens/Wizard.py | 7 +- lib/python/Screens/WizardLanguage.py | 4 - lib/python/Tools/NumericalTextInput.py | 2 +- mytest.py | 15 +- skin.py | 8 +- timer.py | 4 +- 84 files changed, 673 insertions(+), 736 deletions(-) (limited to 'lib/python/Components/NimManager.py') diff --git a/RecordTimer.py b/RecordTimer.py index aeff9d05..9f3b2ffb 100644 --- a/RecordTimer.py +++ b/RecordTimer.py @@ -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" diff --git a/keymapparser.py b/keymapparser.py index 63bca0f9..0e544e94 100644 --- a/keymapparser.py +++ b/keymapparser.py @@ -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"): diff --git a/lib/python/Components/Converter/FrontendInfo.py b/lib/python/Components/Converter/FrontendInfo.py index 796ac330..4043a1be 100644 --- a/lib/python/Components/Converter/FrontendInfo.py +++ b/lib/python/Components/Converter/FrontendInfo.py @@ -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: diff --git a/lib/python/Components/Converter/RdsInfo.py b/lib/python/Components/Converter/RdsInfo.py index 3a7b2be3..f3f2b673 100644 --- a/lib/python/Components/Converter/RdsInfo.py +++ b/lib/python/Components/Converter/RdsInfo.py @@ -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 diff --git a/lib/python/Components/Converter/ServiceInfo.py b/lib/python/Components/Converter/ServiceInfo.py index 71180254..d4054f0c 100644 --- a/lib/python/Components/Converter/ServiceInfo.py +++ b/lib/python/Components/Converter/ServiceInfo.py @@ -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 diff --git a/lib/python/Components/Converter/ServiceName.py b/lib/python/Components/Converter/ServiceName.py index 18b1f2a5..210c1aab 100644 --- a/lib/python/Components/Converter/ServiceName.py +++ b/lib/python/Components/Converter/ServiceName.py @@ -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) diff --git a/lib/python/Components/Converter/ServicePosition.py b/lib/python/Components/Converter/ServicePosition.py index 2bcc5492..b92af40b 100644 --- a/lib/python/Components/Converter/ServicePosition.py +++ b/lib/python/Components/Converter/ServicePosition.py @@ -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: diff --git a/lib/python/Components/Converter/ServiceTime.py b/lib/python/Components/Converter/ServiceTime.py index 89965067..d30839c6 100644 --- a/lib/python/Components/Converter/ServiceTime.py +++ b/lib/python/Components/Converter/ServiceTime.py @@ -16,7 +16,7 @@ class ServiceTime(Converter, object): elif type == "Duration": self.type = self.DURATION else: - raise ElementError("'%s' is not for eEventTime converter" % type) + raise ElementError("'%s' is not for ServiceTime converter" % type) @cached def getTime(self): diff --git a/lib/python/Components/Converter/Streaming.py b/lib/python/Components/Converter/Streaming.py index 2746ee84..0c0d274c 100644 --- a/lib/python/Components/Converter/Streaming.py +++ b/lib/python/Components/Converter/Streaming.py @@ -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 diff --git a/lib/python/Components/DreamInfoHandler.py b/lib/python/Components/DreamInfoHandler.py index c5f82629..2f2e757c 100644 --- a/lib/python/Components/DreamInfoHandler.py +++ b/lib/python/Components/DreamInfoHandler.py @@ -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": diff --git a/lib/python/Components/Element.py b/lib/python/Components/Element.py index f4a8f127..509a1c8d 100644 --- a/lib/python/Components/Element.py +++ b/lib/python/Components/Element.py @@ -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 diff --git a/lib/python/Components/Harddisk.py b/lib/python/Components/Harddisk.py index 75d68fad..8664f79a 100755 --- a/lib/python/Components/Harddisk.py +++ b/lib/python/Components/Harddisk.py @@ -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 diff --git a/lib/python/Components/HelpMenuList.py b/lib/python/Components/HelpMenuList.py index ddf871a7..66139dfb 100755 --- a/lib/python/Components/HelpMenuList.py +++ b/lib/python/Components/HelpMenuList.py @@ -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) ) diff --git a/lib/python/Components/Language.py b/lib/python/Components/Language.py index 74dd67d8..268fdb21 100644 --- a/lib/python/Components/Language.py +++ b/lib/python/Components/Language.py @@ -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): diff --git a/lib/python/Components/NimManager.py b/lib/python/Components/NimManager.py index 75ad3779..48778571 100644 --- a/lib/python/Components/NimManager.py +++ b/lib/python/Components/NimManager.py @@ -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": diff --git a/lib/python/Components/ParentalControl.py b/lib/python/Components/ParentalControl.py index 8c8a3305..d68e01ff 100644 --- a/lib/python/Components/ParentalControl.py +++ b/lib/python/Components/ParentalControl.py @@ -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 diff --git a/lib/python/Components/ParentalControlList.py b/lib/python/Components/ParentalControlList.py index 71912620..128e6d3e 100644 --- a/lib/python/Components/ParentalControlList.py +++ b/lib/python/Components/ParentalControlList.py @@ -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 diff --git a/lib/python/Components/PluginComponent.py b/lib/python/Components/PluginComponent.py index 6e357cd0..fff5c475 100644 --- a/lib/python/Components/PluginComponent.py +++ b/lib/python/Components/PluginComponent.py @@ -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 = [ ] diff --git a/lib/python/Components/PluginList.py b/lib/python/Components/PluginList.py index 63136cce..39c60ff7 100644 --- a/lib/python/Components/PluginList.py +++ b/lib/python/Components/PluginList.py @@ -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): diff --git a/lib/python/Components/Renderer/FrontpanelLed.py b/lib/python/Components/Renderer/FrontpanelLed.py index 7bb584e5..c0083966 100644 --- a/lib/python/Components/Renderer/FrontpanelLed.py +++ b/lib/python/Components/Renderer/FrontpanelLed.py @@ -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 diff --git a/lib/python/Components/Renderer/Picon.py b/lib/python/Components/Renderer/Picon.py index de19c9aa..5ae43ed8 100644 --- a/lib/python/Components/Renderer/Picon.py +++ b/lib/python/Components/Renderer/Picon.py @@ -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) diff --git a/lib/python/Components/Scanner.py b/lib/python/Components/Scanner.py index 17c4aaa8..813c09f8 100644 --- a/lib/python/Components/Scanner.py +++ b/lib/python/Components/Scanner.py @@ -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) diff --git a/lib/python/Components/SelectionList.py b/lib/python/Components/SelectionList.py index a4f1d71a..08af7d02 100644 --- a/lib/python/Components/SelectionList.py +++ b/lib/python/Components/SelectionList.py @@ -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] ] + diff --git a/lib/python/Components/Sources/RdsDecoder.py b/lib/python/Components/Sources/RdsDecoder.py index 3ec9a25d..26a3e5a7 100644 --- a/lib/python/Components/Sources/RdsDecoder.py +++ b/lib/python/Components/Sources/RdsDecoder.py @@ -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)) diff --git a/lib/python/Components/TimerList.py b/lib/python/Components/TimerList.py index a237c364..1109860a 100644 --- a/lib/python/Components/TimerList.py +++ b/lib/python/Components/TimerList.py @@ -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 diff --git a/lib/python/Components/TimerSanityCheck.py b/lib/python/Components/TimerSanityCheck.py index cf505022..c0ca10fa 100644 --- a/lib/python/Components/TimerSanityCheck.py +++ b/lib/python/Components/TimerSanityCheck.py @@ -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 diff --git a/lib/python/Components/Timezones.py b/lib/python/Components/Timezones.py index f3e24ee6..7f709159 100644 --- a/lib/python/Components/Timezones.py +++ b/lib/python/Components/Timezones.py @@ -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" diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py index e3a29b52..79e99b03 100755 --- a/lib/python/Components/config.py +++ b/lib/python/Components/config.py @@ -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): diff --git a/lib/python/Plugins/Extensions/CutListEditor/plugin.py b/lib/python/Plugins/Extensions/CutListEditor/plugin.py index 1ef15a53..ed7cfb70 100644 --- a/lib/python/Plugins/Extensions/CutListEditor/plugin.py +++ b/lib/python/Plugins/Extensions/CutListEditor/plugin.py @@ -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)) diff --git a/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py b/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py index 40b85b70..1c2099fb 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py +++ b/lib/python/Plugins/Extensions/DVDBurn/TitleProperties.py @@ -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() diff --git a/lib/python/Plugins/Extensions/DVDBurn/plugin.py b/lib/python/Plugins/Extensions/DVDBurn/plugin.py index 29076cea..45f438da 100644 --- a/lib/python/Plugins/Extensions/DVDBurn/plugin.py +++ b/lib/python/Plugins/Extensions/DVDBurn/plugin.py @@ -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") ] diff --git a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py index 6a8ffc6f..80629c5d 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py @@ -705,7 +705,7 @@ def filescan(**kwargs): ScanPath(path = "", with_subdirs = False), ], name = "DVD", - description = "Play DVD", + description = _("Play DVD"), openfnc = filescan_open, )] diff --git a/lib/python/Plugins/Extensions/FileManager/plugin.py b/lib/python/Plugins/Extensions/FileManager/plugin.py index 12389813..62c9e7b2 100644 --- a/lib/python/Plugins/Extensions/FileManager/plugin.py +++ b/lib/python/Plugins/Extensions/FileManager/plugin.py @@ -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)] diff --git a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py index e81750ba..e26c65d4 100644 --- a/lib/python/Plugins/Extensions/MediaPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/MediaPlayer/plugin.py @@ -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 diff --git a/lib/python/Plugins/Extensions/MediaScanner/plugin.py b/lib/python/Plugins/Extensions/MediaScanner/plugin.py index 2c31197d..0cefa353 100755 --- a/lib/python/Plugins/Extensions/MediaScanner/plugin.py +++ b/lib/python/Plugins/Extensions/MediaScanner/plugin.py @@ -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) diff --git a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py index 05adb633..10e4e514 100644 --- a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py +++ b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py @@ -586,7 +586,7 @@ def filescan(**kwargs): ScanPath(path = "", with_subdirs = False), ], name = "Pictures", - description = "View Photos...", + description = _("View Photos..."), openfnc = filescan_open, ) diff --git a/lib/python/Plugins/Extensions/SocketMMI/plugin.py b/lib/python/Plugins/Extensions/SocketMMI/plugin.py index 4eadf2ea..387c8306 100644 --- a/lib/python/Plugins/Extensions/SocketMMI/plugin.py +++ b/lib/python/Plugins/Extensions/SocketMMI/plugin.py @@ -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) ] diff --git a/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py b/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py index cbd6bc89..a4793949 100644 --- a/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py +++ b/lib/python/Plugins/SystemPlugins/DiseqcTester/plugin.py @@ -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": diff --git a/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py b/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py index 947452e9..327f08ed 100755 --- a/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py +++ b/lib/python/Plugins/SystemPlugins/SoftwareManager/BackupRestore.py @@ -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 diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py index 6a85c4da..64f79e04 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py @@ -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 diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py index 095e94c0..8f8bea09 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoWizard.py @@ -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: diff --git a/lib/python/Plugins/SystemPlugins/Videomode/plugin.py b/lib/python/Plugins/SystemPlugins/Videomode/plugin.py index 30bdf796..5a7dfd1b 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/plugin.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/plugin.py @@ -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)) diff --git a/lib/python/Screens/About.py b/lib/python/Screens/About.py index e184512b..6cf0f7b4 100644 --- a/lib/python/Screens/About.py +++ b/lib/python/Screens/About.py @@ -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: diff --git a/lib/python/Screens/ChannelSelection.py b/lib/python/Screens/ChannelSelection.py index ebfbe812..bae8f7de 100644 --- a/lib/python/Screens/ChannelSelection.py +++ b/lib/python/Screens/ChannelSelection.py @@ -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() diff --git a/lib/python/Screens/Ci.py b/lib/python/Screens/Ci.py index 5028301e..a997f7fe 100644 --- a/lib/python/Screens/Ci.py +++ b/lib/python/Screens/Ci.py @@ -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() diff --git a/lib/python/Screens/Console.py b/lib/python/Screens/Console.py index c6b156cf..2058c041 100644 --- a/lib/python/Screens/Console.py +++ b/lib/python/Screens/Console.py @@ -11,7 +11,6 @@ class Console(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) diff --git a/lib/python/Screens/DefaultWizard.py b/lib/python/Screens/DefaultWizard.py index 9883dc8e..73b07acf 100644 --- a/lib/python/Screens/DefaultWizard.py +++ b/lib/python/Screens/DefaultWizard.py @@ -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" diff --git a/lib/python/Screens/EpgSelection.py b/lib/python/Screens/EpgSelection.py index e7388fc2..ae96333e 100644 --- a/lib/python/Screens/EpgSelection.py +++ b/lib/python/Screens/EpgSelection.py @@ -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"], { diff --git a/lib/python/Screens/EventView.py b/lib/python/Screens/EventView.py index 6aed1e11..c55d9527 100644 --- a/lib/python/Screens/EventView.py +++ b/lib/python/Screens/EventView.py @@ -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: diff --git a/lib/python/Screens/HarddiskSetup.py b/lib/python/Screens/HarddiskSetup.py index 19a674ec..c9f069fe 100644 --- a/lib/python/Screens/HarddiskSetup.py +++ b/lib/python/Screens/HarddiskSetup.py @@ -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 diff --git a/lib/python/Screens/HelpMenu.py b/lib/python/Screens/HelpMenu.py index abef38db..74882a35 100644 --- a/lib/python/Screens/HelpMenu.py +++ b/lib/python/Screens/HelpMenu.py @@ -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) diff --git a/lib/python/Screens/InfoBar.py b/lib/python/Screens/InfoBar.py index bd9ea182..4d92bd39 100644 --- a/lib/python/Screens/InfoBar.py +++ b/lib/python/Screens/InfoBar.py @@ -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) diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 3f9fe213..e39e028d 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -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): # Reference # - def __init__(self, session, parent): - Screen.__init__(self, session, parent = parent) - class InfoBarSummarySupport: def __init__(self): pass @@ -2108,9 +2108,6 @@ class InfoBarMoviePlayerSummary(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") diff --git a/lib/python/Screens/LanguageSelection.py b/lib/python/Screens/LanguageSelection.py index 94ede08c..082daa55 100644 --- a/lib/python/Screens/LanguageSelection.py +++ b/lib/python/Screens/LanguageSelection.py @@ -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): diff --git a/lib/python/Screens/LocationBox.py b/lib/python/Screens/LocationBox.py index fa47b1f2..61d7105d 100644 --- a/lib/python/Screens/LocationBox.py +++ b/lib/python/Screens/LocationBox.py @@ -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() diff --git a/lib/python/Screens/Menu.py b/lib/python/Screens/Menu.py index 93f23dfb..5f2032f1 100644 --- a/lib/python/Screens/Menu.py +++ b/lib/python/Screens/Menu.py @@ -61,9 +61,6 @@ class MenuSummary(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): diff --git a/lib/python/Screens/MessageBox.py b/lib/python/Screens/MessageBox.py index 8a5989c7..10485680 100644 --- a/lib/python/Screens/MessageBox.py +++ b/lib/python/Screens/MessageBox.py @@ -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() diff --git a/lib/python/Screens/MovieSelection.py b/lib/python/Screens/MovieSelection.py index 5951653f..174a4f07 100644 --- a/lib/python/Screens/MovieSelection.py +++ b/lib/python/Screens/MovieSelection.py @@ -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: diff --git a/lib/python/Screens/Mute.py b/lib/python/Screens/Mute.py index f64be901..f80267ad 100644 --- a/lib/python/Screens/Mute.py +++ b/lib/python/Screens/Mute.py @@ -1,6 +1,5 @@ from Screen import Screen class Mute(Screen): - def __init__(self, session): - Screen.__init__(self, session) + pass diff --git a/lib/python/Screens/NetworkSetup.py b/lib/python/Screens/NetworkSetup.py index ea2d17e6..50f8c41b 100755 --- a/lib/python/Screens/NetworkSetup.py +++ b/lib/python/Screens/NetworkSetup.py @@ -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) diff --git a/lib/python/Screens/NumericalTextInputHelpDialog.py b/lib/python/Screens/NumericalTextInputHelpDialog.py index 39c644b9..e0979587 100644 --- a/lib/python/Screens/NumericalTextInputHelpDialog.py +++ b/lib/python/Screens/NumericalTextInputHelpDialog.py @@ -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 diff --git a/lib/python/Screens/PVRState.py b/lib/python/Screens/PVRState.py index 8b90c420..891379ca 100644 --- a/lib/python/Screens/PVRState.py +++ b/lib/python/Screens/PVRState.py @@ -8,5 +8,5 @@ class PVRState(Screen): self["state"] = Label(text="") class TimeshiftState(PVRState): - def __init__(self, session): - PVRState.__init__(self, session) + pass + diff --git a/lib/python/Screens/ParentalControlSetup.py b/lib/python/Screens/ParentalControlSetup.py index 6ae12cae..4c63dd5c 100644 --- a/lib/python/Screens/ParentalControlSetup.py +++ b/lib/python/Screens/ParentalControlSetup.py @@ -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() diff --git a/lib/python/Screens/PluginBrowser.py b/lib/python/Screens/PluginBrowser.py index 0f6ee746..cd17e2e0 100644 --- a/lib/python/Screens/PluginBrowser.py +++ b/lib/python/Screens/PluginBrowser.py @@ -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) diff --git a/lib/python/Screens/Rc.py b/lib/python/Screens/Rc.py index 3a7c78b3..27ba1abd 100644 --- a/lib/python/Screens/Rc.py +++ b/lib/python/Screens/Rc.py @@ -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 diff --git a/lib/python/Screens/Satconfig.py b/lib/python/Screens/Satconfig.py index da6fcc12..8b5089a3 100644 --- a/lib/python/Screens/Satconfig.py +++ b/lib/python/Screens/Satconfig.py @@ -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) diff --git a/lib/python/Screens/ServiceInfo.py b/lib/python/Screens/ServiceInfo.py index df8af4b4..fa2f4474 100644 --- a/lib/python/Screens/ServiceInfo.py +++ b/lib/python/Screens/ServiceInfo.py @@ -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), diff --git a/lib/python/Screens/Setup.py b/lib/python/Screens/Setup.py index 1d035b8a..7226562f 100644 --- a/lib/python/Screens/Setup.py +++ b/lib/python/Screens/Setup.py @@ -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): """ 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) diff --git a/lib/python/Screens/Standby.py b/lib/python/Screens/Standby.py index d09f28af..afea94b9 100644 --- a/lib/python/Screens/Standby.py +++ b/lib/python/Screens/Standby.py @@ -87,9 +87,6 @@ class StandbySummary(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 diff --git a/lib/python/Screens/SubservicesQuickzap.py b/lib/python/Screens/SubservicesQuickzap.py index 24af517d..3bcc3c46 100644 --- a/lib/python/Screens/SubservicesQuickzap.py +++ b/lib/python/Screens/SubservicesQuickzap.py @@ -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): diff --git a/lib/python/Screens/SubtitleDisplay.py b/lib/python/Screens/SubtitleDisplay.py index 80d3bd26..13ece59a 100644 --- a/lib/python/Screens/SubtitleDisplay.py +++ b/lib/python/Screens/SubtitleDisplay.py @@ -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... diff --git a/lib/python/Screens/Subtitles.py b/lib/python/Screens/Subtitles.py index e6378619..54bc7a5b 100644 --- a/lib/python/Screens/Subtitles.py +++ b/lib/python/Screens/Subtitles.py @@ -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) diff --git a/lib/python/Screens/TaskView.py b/lib/python/Screens/TaskView.py index 69604279..1453c05f 100644 --- a/lib/python/Screens/TaskView.py +++ b/lib/python/Screens/TaskView.py @@ -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() diff --git a/lib/python/Screens/TimeDateInput.py b/lib/python/Screens/TimeDateInput.py index 7f940909..56ccae90 100644 --- a/lib/python/Screens/TimeDateInput.py +++ b/lib/python/Screens/TimeDateInput.py @@ -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) diff --git a/lib/python/Screens/TimerEdit.py b/lib/python/Screens/TimerEdit.py index 6499ef50..caaf8c95 100644 --- a/lib/python/Screens/TimerEdit.py +++ b/lib/python/Screens/TimerEdit.py @@ -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() diff --git a/lib/python/Screens/TimerEntry.py b/lib/python/Screens/TimerEntry.py index 92a16af8..73b2175b 100644 --- a/lib/python/Screens/TimerEntry.py +++ b/lib/python/Screens/TimerEntry.py @@ -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("") diff --git a/lib/python/Screens/TimerSelection.py b/lib/python/Screens/TimerSelection.py index 7a1d9ecd..a97c7ba3 100644 --- a/lib/python/Screens/TimerSelection.py +++ b/lib/python/Screens/TimerSelection.py @@ -22,4 +22,3 @@ class TimerSelection(Screen): def selected(self): self.close(self["timerlist"].getCurrentIndex()) - \ No newline at end of file diff --git a/lib/python/Screens/VirtualKeyBoard.py b/lib/python/Screens/VirtualKeyBoard.py index 5dc1a090..9b676a5f 100755 --- a/lib/python/Screens/VirtualKeyBoard.py +++ b/lib/python/Screens/VirtualKeyBoard.py @@ -1,289 +1,291 @@ -# -*- 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.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_bg)) - res.append(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) +# -*- 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) diff --git a/lib/python/Screens/Wizard.py b/lib/python/Screens/Wizard.py index 7d454f43..555110a4 100755 --- a/lib/python/Screens/Wizard.py +++ b/lib/python/Screens/Wizard.py @@ -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() diff --git a/lib/python/Screens/WizardLanguage.py b/lib/python/Screens/WizardLanguage.py index ec9758d2..91fc80db 100644 --- a/lib/python/Screens/WizardLanguage.py +++ b/lib/python/Screens/WizardLanguage.py @@ -31,7 +31,3 @@ class WizardLanguage(Wizard): self.updateText(firstset = True) self.updateValues() self.updateLanguageDescription() - - - - \ No newline at end of file diff --git a/lib/python/Tools/NumericalTextInput.py b/lib/python/Tools/NumericalTextInput.py index c5576405..df6a5ea8 100644 --- a/lib/python/Tools/NumericalTextInput.py +++ b/lib/python/Tools/NumericalTextInput.py @@ -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 diff --git a/mytest.py b/mytest.py index c335bf2d..efbc34bb 100755 --- 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 6baf6b71..a37716f1 100644 --- 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) diff --git a/timer.py b/timer.py index fd5bb5af..64df9c88 100644 --- 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]) -- cgit v1.2.3 From 472d0fb82d59a7d7ffaa3e7041e0024c7ace0115 Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 23 Mar 2009 13:21:18 +0100 Subject: NimManager.py: create some config entries just when needed .. to speedup enigma2 start --- lib/python/Components/NimManager.py | 406 ++++++++++++++++++++---------------- 1 file changed, 224 insertions(+), 182 deletions(-) (limited to 'lib/python/Components/NimManager.py') diff --git a/lib/python/Components/NimManager.py b/lib/python/Components/NimManager.py index 48778571..6222afea 100644 --- a/lib/python/Components/NimManager.py +++ b/lib/python/Components/NimManager.py @@ -389,20 +389,20 @@ class SecConfigure: else: sec.setLoDirection(rotorParam.WEST) - if currLnb.powerMeasurement.value: - sec.setUseInputpower(True) - sec.setInputpowerDelta(currLnb.powerThreshold.value) - turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW } - if turn_speed_dict.has_key(currLnb.turningSpeed.value): - turning_speed = turn_speed_dict[currLnb.turningSpeed.value] + if currLnb.powerMeasurement.value: + sec.setUseInputpower(True) + sec.setInputpowerDelta(currLnb.powerThreshold.value) + turn_speed_dict = { "fast": rotorParam.FAST, "slow": rotorParam.SLOW } + if turn_speed_dict.has_key(currLnb.turningSpeed.value): + turning_speed = turn_speed_dict[currLnb.turningSpeed.value] + else: + beg_time = localtime(currLnb.fastTurningBegin.value) + end_time = localtime(currLnb.fastTurningEnd.value) + turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16 + turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1 + sec.setRotorTurningSpeed(turning_speed) else: - beg_time = localtime(currLnb.fastTurningBegin.value) - end_time = localtime(currLnb.fastTurningEnd.value) - turning_speed = ((beg_time.tm_hour + 1) * 60 + beg_time.tm_min + 1) << 16 - turning_speed |= (end_time.tm_hour + 1) * 60 + end_time.tm_min + 1 - sec.setRotorTurningSpeed(turning_speed) - else: - sec.setUseInputpower(False) + sec.setUseInputpower(False) sec.setLNBSlotMask(tunermask) @@ -856,7 +856,7 @@ def InitSecParams(): config.sec.delay_after_last_diseqc_command = x x = ConfigInteger(default=50, limits = (0, 9999)) - x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value)) + x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value), initial_call = False) config.sec.delay_after_toneburst = x x = ConfigInteger(default=20, limits = (0, 9999)) @@ -926,57 +926,58 @@ def InitNimManager(nimmgr): "unicable": _("Unicable"), "c_band": _("C-Band"), "user_defined": _("User defined")} + lnb_choices_default = "universal_lnb" unicablelnbproducts = { - "Humax": {"150 SCR":["1210","1420","1680","2040"]}, - "Inverto": {"IDLP-40UNIQD+S":["1680","1420","2040","1210"]}, - "Kathrein": {"UAS481":["1400","1516","1632","1748"]}, - "Kreiling": {"KR1440":["1680","1420","2040","1210"]}, - "Radix": {"Unicable LNB":["1680","1420","2040","1210"]}, - "Wisi": {"OC 05":["1210","1420","1680","2040"]}} + "Humax": {"150 SCR":("1210","1420","1680","2040")}, + "Inverto": {"IDLP-40UNIQD+S":("1680","1420","2040","1210")}, + "Kathrein": {"UAS481":("1400","1516","1632","1748")}, + "Kreiling": {"KR1440":("1680","1420","2040","1210")}, + "Radix": {"Unicable LNB":("1680","1420","2040","1210")}, + "Wisi": {"OC 05":("1210","1420","1680","2040")}} UnicableLnbManufacturers = unicablelnbproducts.keys() UnicableLnbManufacturers.sort() unicablematrixproducts = { "Ankaro": { - "UCS 51440":["1400","1632","1284","1516"], - "UCS 51820":["1400","1632","1284","1516","1864","2096","1748","1980"], - "UCS 51840":["1400","1632","1284","1516","1864","2096","1748","1980"], - "UCS 52240":["1400","1632"], - "UCS 52420":["1400","1632","1284","1516"], - "UCS 52440":["1400","1632","1284","1516"], - "UCS 91440":["1400","1632","1284","1516"], - "UCS 91820":["1400","1632","1284","1516","1864","2096","1748","1980"], - "UCS 91840":["1400","1632","1284","1516","1864","2096","1748","1980"], - "UCS 92240":["1400","1632"], - "UCS 92420":["1400","1632","1284","1516"], - "UCS 92440":["1400","1632","1284","1516"]}, + "UCS 51440":("1400","1632","1284","1516"), + "UCS 51820":("1400","1632","1284","1516","1864","2096","1748","1980"), + "UCS 51840":("1400","1632","1284","1516","1864","2096","1748","1980"), + "UCS 52240":("1400","1632"), + "UCS 52420":("1400","1632","1284","1516"), + "UCS 52440":("1400","1632","1284","1516"), + "UCS 91440":("1400","1632","1284","1516"), + "UCS 91820":("1400","1632","1284","1516","1864","2096","1748","1980"), + "UCS 91840":("1400","1632","1284","1516","1864","2096","1748","1980"), + "UCS 92240":("1400","1632"), + "UCS 92420":("1400","1632","1284","1516"), + "UCS 92440":("1400","1632","1284","1516")}, "DCT Delta": { - "SUM518":["1284","1400","1516","1632","1748","1864","1980","2096"], - "SUM918":["1284","1400","1516","1632","1748","1864","1980","2096"], - "SUM928":["1284","1400","1516","1632","1748","1864","1980","2096"]}, + "SUM518":("1284","1400","1516","1632","1748","1864","1980","2096"), + "SUM918":("1284","1400","1516","1632","1748","1864","1980","2096"), + "SUM928":("1284","1400","1516","1632","1748","1864","1980","2096")}, "Inverto": { - "IDLP-UST11O-CUO1O-8PP":["1076","1178","1280","1382","1484","1586","1688","1790"]}, + "IDLP-UST11O-CUO1O-8PP":("1076","1178","1280","1382","1484","1586","1688","1790")}, "Kathrein": { - "EXR501":["1400","1516","1632","1748"], - "EXR551":["1400","1516","1632","1748"], - "EXR552":["1400","1516"]}, + "EXR501":("1400","1516","1632","1748"), + "EXR551":("1400","1516","1632","1748"), + "EXR552":("1400","1516")}, "ROTEK": { - "EKL2/1":["1400","1516"], - "EKL2/1E":["0","0","1632","1748"]}, + "EKL2/1":("1400","1516"), + "EKL2/1E":("0","0","1632","1748")}, "Smart": { - "DPA 51":["1284","1400","1516","1632","1748","1864","1980","2096"]}, + "DPA 51":("1284","1400","1516","1632","1748","1864","1980","2096")}, "Technisat": { - "TechniRouter 5/1x8 G":["1284","1400","1516","1632","1748","1864","1980","2096"], - "TechniRouter 5/1x8 K":["1284","1400","1516","1632","1748","1864","1980","2096"], - "TechniRouter 5/2x4 G":["1284","1400","1516","1632"], - "TechniRouter 5/2x4 K":["1284","1400","1516","1632"]}, + "TechniRouter 5/1x8 G":("1284","1400","1516","1632","1748","1864","1980","2096"), + "TechniRouter 5/1x8 K":("1284","1400","1516","1632","1748","1864","1980","2096"), + "TechniRouter 5/2x4 G":("1284","1400","1516","1632"), + "TechniRouter 5/2x4 K":("1284","1400","1516","1632")}, "Telstar": { - "SCR 5/1x8 G":["1284","1400","1516","1632","1748","1864","1980","2096"], - "SCR 5/1x8 K":["1284","1400","1516","1632","1748","1864","1980","2096"], - "SCR 5/2x4 G":["1284","1400","1516","1632"], - "SCR 5/2x4 K":["1284","1400","1516","1632"]}} + "SCR 5/1x8 G":("1284","1400","1516","1632","1748","1864","1980","2096"), + "SCR 5/1x8 K":("1284","1400","1516","1632","1748","1864","1980","2096"), + "SCR 5/2x4 G":("1284","1400","1516","1632"), + "SCR 5/2x4 K":("1284","1400","1516","1632")}} UnicableMatrixManufacturers = unicablematrixproducts.keys() UnicableMatrixManufacturers.sort() @@ -986,59 +987,9 @@ def InitNimManager(nimmgr): "unicable_user": "Unicable "+_("User defined")} unicable_choices_default = "unicable_lnb" - unicableLnb = ConfigSubDict() - for y in unicablelnbproducts: - products = unicablelnbproducts[y].keys() - products.sort() - unicableLnb[y] = ConfigSubsection() - unicableLnb[y].product = ConfigSelection(choices = products, default = products[0]) - unicableLnb[y].scr = ConfigSubDict() - unicableLnb[y].vco = ConfigSubDict() - for z in products: - scrlist = [] - vcolist = unicablelnbproducts[y][z] - unicableLnb[y].vco[z] = ConfigSubList() - for cnt in range(1,1+len(vcolist)): - scrlist.append(("%d" %cnt,"SCR %d" %cnt)) - vcofreq = int(vcolist[cnt-1]) - unicableLnb[y].vco[z].append(ConfigInteger(default=vcofreq, limits = (vcofreq, vcofreq))) - unicableLnb[y].scr[z] = ConfigSelection(choices = scrlist, default = scrlist[0][0]) - - unicableMatrix = ConfigSubDict() - - for y in unicablematrixproducts: - products = unicablematrixproducts[y].keys() - products.sort() - unicableMatrix[y] = ConfigSubsection() - unicableMatrix[y].product = ConfigSelection(choices = products, default = products[0]) - unicableMatrix[y].scr = ConfigSubDict() - unicableMatrix[y].vco = ConfigSubDict() - for z in products: - scrlist = [] - vcolist = unicablematrixproducts[y][z] - unicableMatrix[y].vco[z] = ConfigSubList() - for cnt in range(1,1+len(vcolist)): - vcofreq = int(vcolist[cnt-1]) - if vcofreq == 0: - scrlist.append(("%d" %cnt,"SCR %d " %cnt +_("not used"))) - else: - scrlist.append(("%d" %cnt,"SCR %d" %cnt)) - unicableMatrix[y].vco[z].append(ConfigInteger(default=vcofreq, limits = (vcofreq, vcofreq))) - unicableMatrix[y].scr[z] = ConfigSelection(choices = scrlist, default = scrlist[0][0]) - advanced_lnb_satcruser_choices = [ ("1", "SatCR 1"), ("2", "SatCR 2"), ("3", "SatCR 3"), ("4", "SatCR 4"), ("5", "SatCR 5"), ("6", "SatCR 6"), ("7", "SatCR 7"), ("8", "SatCR 8")] - satcrvcouser = ConfigSubList() - satcrvcouser.append(ConfigInteger(default=1284, limits = (0, 9999))) - satcrvcouser.append(ConfigInteger(default=1400, limits = (0, 9999))) - satcrvcouser.append(ConfigInteger(default=1516, limits = (0, 9999))) - satcrvcouser.append(ConfigInteger(default=1632, limits = (0, 9999))) - satcrvcouser.append(ConfigInteger(default=1748, limits = (0, 9999))) - satcrvcouser.append(ConfigInteger(default=1864, limits = (0, 9999))) - satcrvcouser.append(ConfigInteger(default=1980, limits = (0, 9999))) - satcrvcouser.append(ConfigInteger(default=2096, limits = (0, 9999))) - prio_list = [ ("-1", _("Auto")) ] prio_list += [(str(prio), str(prio)) for prio in range(65)+range(14000,14065)+range(19000,19065)] @@ -1077,26 +1028,174 @@ def InitNimManager(nimmgr): advanced_lnb_diseqc_repeat_choices = [("none", _("None")), ("one", _("One")), ("two", _("Two")), ("three", _("Three"))] advanced_lnb_fast_turning_btime = mktime(datetime(1970, 1, 1, 7, 0).timetuple()); advanced_lnb_fast_turning_etime = mktime(datetime(1970, 1, 1, 19, 0).timetuple()); + + def configLOFChanged(configElement): + if configElement.value == "unicable": + x = configElement.slot_id + lnb = configElement.lnb_id + nim = config.Nims[x] + lnbs = nim.advanced.lnb + section = lnbs[lnb] + if isinstance(section.unicable, ConfigNothing): + if lnb == 1: + section.unicable = ConfigSelection(unicable_choices, unicable_choices_default) + elif lnb == 2: + section.unicable = ConfigSelection(choices = {"unicable_matrix": _("Unicable Martix"),"unicable_user": "Unicable "+_("User defined")}, default = "unicable_matrix") + else: + section.unicable = ConfigSelection(choices = {"unicable_user": _("User defined")}, default = "unicable_user") + + if lnb < 3: + section.unicableMatrix = ConfigSubDict() + section.unicableMatrixManufacturer = ConfigSelection(choices = UnicableMatrixManufacturers, default = UnicableMatrixManufacturers[0]) + for y in unicablematrixproducts: + products = unicablematrixproducts[y].keys() + products.sort() + tmp = ConfigSubsection() + tmp.product = ConfigSelection(choices = products, default = products[0]) + tmp.scr = ConfigSubDict() + tmp.vco = ConfigSubDict() + for z in products: + scrlist = [] + vcolist = unicablematrixproducts[y][z] + tmp.vco[z] = ConfigSubList() + for cnt in range(1,1+len(vcolist)): + vcofreq = int(vcolist[cnt-1]) + if vcofreq == 0: + scrlist.append(("%d" %cnt,"SCR %d " %cnt +_("not used"))) + else: + scrlist.append(("%d" %cnt,"SCR %d" %cnt)) + tmp.vco[z].append(ConfigInteger(default=vcofreq, limits = (vcofreq, vcofreq))) + tmp.scr[z] = ConfigSelection(choices = scrlist, default = scrlist[0][0]) + section.unicableMatrix[y] = tmp + + if lnb < 2: + section.unicableLnb = ConfigSubDict() + section.unicableLnbManufacturer = ConfigSelection(UnicableLnbManufacturers, UnicableLnbManufacturers[0]) + for y in unicablelnbproducts: + products = unicablelnbproducts[y].keys() + products.sort() + tmp = ConfigSubsection() + tmp.product = ConfigSelection(choices = products, default = products[0]) + tmp.scr = ConfigSubDict() + tmp.vco = ConfigSubDict() + for z in products: + scrlist = [] + vcolist = unicablelnbproducts[y][z] + tmp.vco[z] = ConfigSubList() + for cnt in range(1,1+len(vcolist)): + scrlist.append(("%d" %cnt,"SCR %d" %cnt)) + vcofreq = int(vcolist[cnt-1]) + tmp.vco[z].append(ConfigInteger(default=vcofreq, limits = (vcofreq, vcofreq))) + tmp.scr[z] = ConfigSelection(choices = scrlist, default = scrlist[0][0]) + section.unicableLnb[y] = tmp + + section.satcruser = ConfigSelection(advanced_lnb_satcruser_choices, default="1") + tmp = ConfigSubList() + tmp.append(ConfigInteger(default=1284, limits = (0, 9999))) + tmp.append(ConfigInteger(default=1400, limits = (0, 9999))) + tmp.append(ConfigInteger(default=1516, limits = (0, 9999))) + tmp.append(ConfigInteger(default=1632, limits = (0, 9999))) + tmp.append(ConfigInteger(default=1748, limits = (0, 9999))) + tmp.append(ConfigInteger(default=1864, limits = (0, 9999))) + tmp.append(ConfigInteger(default=1980, limits = (0, 9999))) + tmp.append(ConfigInteger(default=2096, limits = (0, 9999))) + section.satcrvcouser = tmp + + def configDiSEqCModeChanged(configElement): + section = configElement.section + if configElement.value == "1_2" and isinstance(section.longitude, ConfigNothing): + section.longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)]) + section.longitudeOrientation = ConfigSelection(longitude_orientation_choices, "east") + section.latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)]) + section.latitudeOrientation = ConfigSelection(latitude_orientation_choices, "north") + section.powerMeasurement = ConfigYesNo(default=True) + section.powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100)) + section.turningSpeed = ConfigSelection(turning_speed_choices, "fast") + section.fastTurningBegin = ConfigDateTime(default=advanced_lnb_fast_turning_btime, formatstring = _("%H:%M"), increment = 600) + section.fastTurningEnd = ConfigDateTime(default=advanced_lnb_fast_turning_etime, formatstring = _("%H:%M"), increment = 600) + + def configLNBChanged(configElement): + x = configElement.slot_id + nim = config.Nims[x] + if isinstance(configElement.value, tuple): + lnb = int(configElement.value[0]) + else: + lnb = int(configElement.value) + lnbs = nim.advanced.lnb + if lnb and lnb not in lnbs: + section = lnbs[lnb] = ConfigSubsection() + section.lofl = ConfigInteger(default=9750, limits = (0, 99999)) + section.lofh = ConfigInteger(default=10600, limits = (0, 99999)) + section.threshold = ConfigInteger(default=11700, limits = (0, 99999)) +# section.output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V") + section.increased_voltage = ConfigYesNo(False) + section.toneburst = ConfigSelection(advanced_lnb_toneburst_choices, "none") + section.longitude = ConfigNothing() + if lnb > 32: + tmp = ConfigSelection(advanced_lnb_allsat_diseqcmode_choices, "1_2") + tmp.section = section + configDiSEqCModeChanged(tmp) + else: + tmp = ConfigSelection(advanced_lnb_diseqcmode_choices, "none") + tmp.section = section + tmp.addNotifier(configDiSEqCModeChanged) + section.diseqcMode = tmp + section.commitedDiseqcCommand = ConfigSelection(advanced_lnb_csw_choices) + section.fastDiseqc = ConfigYesNo(False) + section.sequenceRepeat = ConfigYesNo(False) + section.commandOrder1_0 = ConfigSelection(advanced_lnb_commandOrder1_0_choices, "ct") + section.commandOrder = ConfigSelection(advanced_lnb_commandOrder_choices, "ct") + section.uncommittedDiseqcCommand = ConfigSelection(advanced_lnb_ucsw_choices) + section.diseqcRepeats = ConfigSelection(advanced_lnb_diseqc_repeat_choices, "none") + section.prio = ConfigSelection(prio_list, "-1") + section.unicable = ConfigNothing() + tmp = ConfigSelection(lnb_choices, lnb_choices_default) + tmp.slot_id = x + tmp.lnb_id = lnb + tmp.addNotifier(configLOFChanged, initial_call = False) + section.lof = tmp + + def configModeChanged(configMode): + slot_id = configMode.slot_id + nim = config.Nims[slot_id] + if configMode.value == "advanced" and isinstance(nim.advanced, ConfigNothing): + # advanced config: + nim.advanced = ConfigSubsection() + nim.advanced.sat = ConfigSubDict() + nim.advanced.sats = getConfigSatlist(192, advanced_satlist_choices) + nim.advanced.lnb = ConfigSubDict() + nim.advanced.lnb[0] = ConfigNothing() + for x in nimmgr.satList: + tmp = ConfigSubsection() + tmp.voltage = ConfigSelection(advanced_voltage_choices, "polarization") + tmp.tonemode = ConfigSelection(advanced_tonemode_choices, "band") + tmp.usals = ConfigYesNo(True) + tmp.rotorposition = ConfigInteger(default=1, limits=(1, 255)) + lnb = ConfigSelection(advanced_lnb_choices, "0") + lnb.slot_id = slot_id + lnb.addNotifier(configLNBChanged, initial_call = False) + tmp.lnb = lnb + nim.advanced.sat[x[0]] = tmp + for x in range(3601, 3605): + tmp = ConfigSubsection() + tmp.voltage = ConfigSelection(advanced_voltage_choices, "polarization") + tmp.tonemode = ConfigSelection(advanced_tonemode_choices, "band") + tmp.usals = ConfigYesNo(default=True) + tmp.rotorposition = ConfigInteger(default=1, limits=(1, 255)) + lnbnum = 33+x-3601 + lnb = ConfigSelection([("0", "not available"), (str(lnbnum), "LNB %d"%(lnbnum))], "0") + lnb.slot_id = slot_id + lnb.addNotifier(configLNBChanged, initial_call = False) + tmp.lnb = lnb + nim.advanced.sat[x] = tmp + for slot in nimmgr.nim_slots: x = slot.slot nim = config.Nims[x] - if slot.isCompatible("DVB-S"): - config_mode_choices = [ ("nothing", _("nothing connected")), - ("simple", _("simple")), ("advanced", _("advanced"))] - if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0: - config_mode_choices.append(("equal", _("equal to"))) - config_mode_choices.append(("satposdepends", _("second cable of motorized LNB"))) - if len(nimmgr.canConnectTo(x)) > 0: - config_mode_choices.append(("loopthrough", _("loopthrough to"))) - nim.configMode = ConfigSelection(config_mode_choices, "nothing") - nim.diseqc13V = ConfigYesNo(False) - nim.diseqcMode = ConfigSelection(diseqc_mode_choices, "diseqc_a_b") - nim.connectedTo = ConfigSelection([(str(id), nimmgr.getNimDescription(id)) for id in nimmgr.getNimListOfType("DVB-S") if id != x]) - nim.simpleSingleSendDiSEqC = ConfigYesNo(False) nim.simpleDiSEqCSetVoltageTone = ConfigYesNo(True) nim.simpleDiSEqCOnlyOnSatChange = ConfigYesNo(False) @@ -1116,75 +1215,18 @@ def InitNimManager(nimmgr): nim.fastTurningBegin = ConfigDateTime(default = mktime(btime.timetuple()), formatstring = _("%H:%M"), increment = 900) etime = datetime(1970, 1, 1, 19, 0); nim.fastTurningEnd = ConfigDateTime(default = mktime(etime.timetuple()), formatstring = _("%H:%M"), increment = 900) - - # advanced config: - nim.advanced = ConfigSubsection() - nim.advanced.sats = getConfigSatlist(192, advanced_satlist_choices) - nim.advanced.sat = ConfigSubDict() - - for x in nimmgr.satList: - nim.advanced.sat[x[0]] = ConfigSubsection() - nim.advanced.sat[x[0]].voltage = ConfigSelection(advanced_voltage_choices, "polarization") - nim.advanced.sat[x[0]].tonemode = ConfigSelection(advanced_tonemode_choices, "band") - nim.advanced.sat[x[0]].usals = ConfigYesNo(True) - nim.advanced.sat[x[0]].rotorposition = ConfigInteger(default=1, limits=(1, 255)) - nim.advanced.sat[x[0]].lnb = ConfigSelection(advanced_lnb_choices, "0") - - for x in range(3601, 3605): - nim.advanced.sat[x] = ConfigSubsection() - nim.advanced.sat[x].voltage = ConfigSelection(advanced_voltage_choices, "polarization") - nim.advanced.sat[x].tonemode = ConfigSelection(advanced_tonemode_choices, "band") - nim.advanced.sat[x].usals = ConfigYesNo(default=True) - nim.advanced.sat[x].rotorposition = ConfigInteger(default=1, limits=(1, 255)) - lnbnum = 33+x-3601 - nim.advanced.sat[x].lnb = ConfigSelection([("0", "not available"), (str(lnbnum), "LNB %d"%(lnbnum))], "0") - - nim.advanced.lnb = ConfigSubList() - nim.advanced.lnb.append(ConfigNothing()) - - for x in range(1, 37): - nim.advanced.lnb.append(ConfigSubsection()) - nim.advanced.lnb[x].lof = ConfigSelection(lnb_choices, lnb_choices_default) - - nim.advanced.lnb[x].lofl = ConfigInteger(default=9750, limits = (0, 99999)) - nim.advanced.lnb[x].lofh = ConfigInteger(default=10600, limits = (0, 99999)) - nim.advanced.lnb[x].threshold = ConfigInteger(default=11700, limits = (0, 99999)) - - nim.advanced.lnb[x].unicable = ConfigSelection(unicable_choices, unicable_choices_default) - - nim.advanced.lnb[x].unicableLnb = unicableLnb # is this okay? all lnb use the same ConfigSubDict ? ! ? - nim.advanced.lnb[x].unicableLnbManufacturer = ConfigSelection(UnicableLnbManufacturers, UnicableLnbManufacturers[0]) - - nim.advanced.lnb[x].unicableMatrix = unicableMatrix # is this okay? all lnb use the same ConfigSubDict ? ! ? - nim.advanced.lnb[x].unicableMatrixManufacturer = ConfigSelection(UnicableMatrixManufacturers, UnicableMatrixManufacturers[0]) - - nim.advanced.lnb[x].satcruser = ConfigSelection(advanced_lnb_satcruser_choices, "1") - nim.advanced.lnb[x].satcrvcouser = satcrvcouser # is this okay? all lnb use the same ConfigSubDict ? ! ? - -# nim.advanced.lnb[x].output_12v = ConfigSelection(choices = [("0V", _("0 V")), ("12V", _("12 V"))], default="0V") - nim.advanced.lnb[x].increased_voltage = ConfigYesNo(False) - nim.advanced.lnb[x].toneburst = ConfigSelection(advanced_lnb_toneburst_choices, "none") - if x > 32: - nim.advanced.lnb[x].diseqcMode = ConfigSelection(advanced_lnb_allsat_diseqcmode_choices, "1_2") - else: - nim.advanced.lnb[x].diseqcMode = ConfigSelection(advanced_lnb_diseqcmode_choices, "none") - nim.advanced.lnb[x].commitedDiseqcCommand = ConfigSelection(advanced_lnb_csw_choices) - nim.advanced.lnb[x].fastDiseqc = ConfigYesNo(False) - nim.advanced.lnb[x].sequenceRepeat = ConfigYesNo(False) - nim.advanced.lnb[x].commandOrder1_0 = ConfigSelection(advanced_lnb_commandOrder1_0_choices, "ct") - nim.advanced.lnb[x].commandOrder = ConfigSelection(advanced_lnb_commandOrder_choices, "ct") - nim.advanced.lnb[x].uncommittedDiseqcCommand = ConfigSelection(advanced_lnb_ucsw_choices) - nim.advanced.lnb[x].diseqcRepeats = ConfigSelection(advanced_lnb_diseqc_repeat_choices, "none") - nim.advanced.lnb[x].longitude = ConfigFloat(default = [5,100], limits = [(0,359),(0,999)]) - nim.advanced.lnb[x].longitudeOrientation = ConfigSelection(longitude_orientation_choices, "east") - nim.advanced.lnb[x].latitude = ConfigFloat(default = [50,767], limits = [(0,359),(0,999)]) - nim.advanced.lnb[x].latitudeOrientation = ConfigSelection(latitude_orientation_choices, "north") - nim.advanced.lnb[x].powerMeasurement = ConfigYesNo(default=True) - nim.advanced.lnb[x].powerThreshold = ConfigInteger(default=hw.get_device_name() == "dm8000" and 15 or 50, limits=(0, 100)) - nim.advanced.lnb[x].turningSpeed = ConfigSelection(turning_speed_choices, "fast") - nim.advanced.lnb[x].fastTurningBegin = ConfigDateTime(default=advanced_lnb_fast_turning_btime, formatstring = _("%H:%M"), increment = 600) - nim.advanced.lnb[x].fastTurningEnd = ConfigDateTime(default=advanced_lnb_fast_turning_etime, formatstring = _("%H:%M"), increment = 600) - nim.advanced.lnb[x].prio = ConfigSelection(prio_list, "-1") + config_mode_choices = [ ("nothing", _("nothing connected")), + ("simple", _("simple")), ("advanced", _("advanced"))] + if len(nimmgr.getNimListOfType(slot.type, exception = x)) > 0: + config_mode_choices.append(("equal", _("equal to"))) + config_mode_choices.append(("satposdepends", _("second cable of motorized LNB"))) + if len(nimmgr.canConnectTo(x)) > 0: + config_mode_choices.append(("loopthrough", _("loopthrough to"))) + nim.advanced = ConfigNothing() + tmp = ConfigSelection(config_mode_choices, "nothing") + tmp.slot_id = x + tmp.addNotifier(configModeChanged, initial_call = False) + nim.configMode = tmp elif slot.isCompatible("DVB-C"): nim.configMode = ConfigSelection( choices = { -- cgit v1.2.3 From b9f48c64a16e501cc2d5bf28a9ab89aceb51c10c Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 23 Mar 2009 14:43:20 +0100 Subject: NimManager.py: small revert --- lib/python/Components/NimManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/python/Components/NimManager.py') diff --git a/lib/python/Components/NimManager.py b/lib/python/Components/NimManager.py index 6222afea..aa915937 100644 --- a/lib/python/Components/NimManager.py +++ b/lib/python/Components/NimManager.py @@ -856,7 +856,7 @@ def InitSecParams(): config.sec.delay_after_last_diseqc_command = x x = ConfigInteger(default=50, limits = (0, 9999)) - x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value), initial_call = False) + x.addNotifier(lambda configElement: secClass.setParam(secClass.DELAY_AFTER_TONEBURST, configElement.value)) config.sec.delay_after_toneburst = x x = ConfigInteger(default=20, limits = (0, 9999)) -- cgit v1.2.3