diff options
| author | Fraxinas <andreas.frisch@multimedia-labs.de> | 2009-03-02 17:32:02 +0100 |
|---|---|---|
| committer | Fraxinas <andreas.frisch@multimedia-labs.de> | 2009-03-02 17:32:02 +0100 |
| commit | e68a1617b7c1efbedf8b28309943dd7669daaad0 (patch) | |
| tree | 2c45f065213b18f3a2c8a5e8666977f9bbff230d /lib/python/Components | |
| parent | 8d2545bc513280abe52d9c0fc2b704de3729a11e (diff) | |
| parent | fe12fe9e0ab3a4f9751b67c0aa3751d5864784ba (diff) | |
| download | enigma2-e68a1617b7c1efbedf8b28309943dd7669daaad0.tar.gz enigma2-e68a1617b7c1efbedf8b28309943dd7669daaad0.zip | |
Merge branch 'master' of fraxinas@git.opendreambox.org:/git/enigma2
Diffstat (limited to 'lib/python/Components')
26 files changed, 109 insertions, 141 deletions
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 <StartTime|EndTime|Duration> for eEventTime converter" % type) + raise ElementError("'%s' is not <StartTime|EndTime|Duration> 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): |
