diff options
Diffstat (limited to 'lib/python/Screens')
| -rw-r--r-- | lib/python/Screens/InfoBar.py | 44 | ||||
| -rw-r--r-- | lib/python/Screens/InfoBarGenerics.py | 114 | ||||
| -rw-r--r-- | lib/python/Screens/LocationBox.py | 23 | ||||
| -rw-r--r-- | lib/python/Screens/PluginBrowser.py | 13 | ||||
| -rw-r--r-- | lib/python/Screens/ServiceInfo.py | 2 | ||||
| -rw-r--r-- | lib/python/Screens/TimerEdit.py | 9 | ||||
| -rw-r--r-- | lib/python/Screens/TimerEntry.py | 2 | ||||
| -rwxr-xr-x | lib/python/Screens/Wizard.py | 6 |
8 files changed, 114 insertions, 99 deletions
diff --git a/lib/python/Screens/InfoBar.py b/lib/python/Screens/InfoBar.py index 31a32563..bd9ea182 100644 --- a/lib/python/Screens/InfoBar.py +++ b/lib/python/Screens/InfoBar.py @@ -159,15 +159,19 @@ class MoviePlayer(InfoBarBase, InfoBarShowHide, \ def handleLeave(self, how): self.is_closing = True if how == "ask": - list = [] - list.append((_("Yes"), "quit")) - if config.usage.setup_level.index >= 2: # expert+ - list.append((_("Yes, returning to movie list"), "movielist")) - if config.usage.setup_level.index >= 2: # expert+ - list.append((_("Yes, and delete this movie"), "quitanddelete")) - list.append((_("No"), "continue")) - if config.usage.setup_level.index >= 2: # expert+ - list.append((_("No, but restart from begin"), "restart")) + if config.usage.setup_level.index < 2: # -expert + list = ( + (_("Yes"), "quit"), + (_("No"), "continue") + ) + else: + list = ( + (_("Yes"), "quit"), + (_("Yes, returning to movie list"), "movielist"), + (_("Yes, and delete this movie"), "quitanddelete"), + (_("No"), "continue"), + (_("No, but restart from begin"), "restart") + ) from Screens.ChoiceBox import ChoiceBox self.session.openWithCallback(self.leavePlayerConfirmed, ChoiceBox, title=_("Stop playing this movie?"), list = list) @@ -184,26 +188,26 @@ class MoviePlayer(InfoBarBase, InfoBarShowHide, \ def leavePlayerConfirmed(self, answer): answer = answer and answer[1] - if answer in ["quitanddelete", "quitanddeleteconfirmed"]: + if answer in ("quitanddelete", "quitanddeleteconfirmed"): ref = self.session.nav.getCurrentlyPlayingServiceReference() from enigma import eServiceCenter serviceHandler = eServiceCenter.getInstance() info = serviceHandler.info(ref) name = info and info.getName(ref) or _("this recording") - if answer == "quitanddelete": - from Screens.MessageBox import MessageBox - self.session.openWithCallback(self.deleteConfirmed, MessageBox, _("Do you really want to delete %s?") % name) - return - - if answer == "quitanddeleteconfirmed": - offline = serviceHandler.offlineOperations(ref) - if offline.deleteFromDisk(0): + if answer == "quitanddelete": from Screens.MessageBox import MessageBox - self.session.openWithCallback(self.close, MessageBox, _("You cannot delete this!"), MessageBox.TYPE_ERROR) + self.session.openWithCallback(self.deleteConfirmed, MessageBox, _("Do you really want to delete %s?") % name) return - if answer in ["quit", "quitanddeleteconfirmed"]: + elif answer == "quitanddeleteconfirmed": + offline = serviceHandler.offlineOperations(ref) + if offline.deleteFromDisk(0): + from Screens.MessageBox import MessageBox + self.session.openWithCallback(self.close, MessageBox, _("You cannot delete this!"), MessageBox.TYPE_ERROR) + return + + if answer in ("quit", "quitanddeleteconfirmed"): config.movielist.last_videodir.cancel() self.close() elif answer == "movielist": diff --git a/lib/python/Screens/InfoBarGenerics.py b/lib/python/Screens/InfoBarGenerics.py index 6e28f84a..a50c10be 100644 --- a/lib/python/Screens/InfoBarGenerics.py +++ b/lib/python/Screens/InfoBarGenerics.py @@ -490,10 +490,9 @@ class InfoBarEPG: self.session.open(EPGSelection, ref) def showEventInfoPlugins(self): - list = [] - for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EVENTINFO): - list.append((p.name, boundFunction(self.runPlugin, p))) - if len(list): + list = [(p.name, boundFunction(self.runPlugin, p)) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EVENTINFO)] + + if list: list.append((_("show single service EPG..."), self.openSingleServiceEPG)) self.session.openWithCallback(self.EventInfoPluginChosen, ChoiceBox, title=_("Please choose an extension..."), list = list) else: @@ -510,38 +509,40 @@ class InfoBarEPG: self.session.open(EPGSelection, refstr, None, eventid) def getNowNext(self): - self.epglist = [ ] + epglist = [ ] service = self.session.nav.getCurrentService() info = service and service.info() ptr = info and info.getEvent(0) if ptr: - self.epglist.append(ptr) + epglist.append(ptr) ptr = info and info.getEvent(1) if ptr: - self.epglist.append(ptr) + epglist.append(ptr) + self.epglist = epglist def __evEventInfoChanged(self): if self.is_now_next and len(self.dlg_stack) == 1: self.getNowNext() assert self.eventView - if len(self.epglist): + if self.epglist: self.eventView.setEvent(self.epglist[0]) def openEventView(self): ref = self.session.nav.getCurrentlyPlayingServiceReference() self.getNowNext() - if len(self.epglist) == 0: + epglist = self.epglist + if not epglist: self.is_now_next = False epg = eEPGCache.getInstance() ptr = ref and ref.valid() and epg.lookupEventTime(ref, -1) if ptr: - self.epglist.append(ptr) + epglist.append(ptr) ptr = epg.lookupEventTime(ref, ptr.getBeginTime(), +1) if ptr: - self.epglist.append(ptr) + epglist.append(ptr) else: self.is_now_next = True - if len(self.epglist) > 0: + if epglist: self.eventView = self.session.openWithCallback(self.closed, EventViewEPGSelect, self.epglist[0], ServiceReference(ref), self.eventViewCallback, self.openSingleServiceEPG, self.openMultiServiceEPG, self.openSimilarList) self.dlg_stack.append(self.eventView) else: @@ -549,11 +550,12 @@ class InfoBarEPG: self.openMultiServiceEPG(False) 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 InfoBarRdsDecoder: """provides RDS and Rass support/display""" @@ -712,7 +714,7 @@ class InfoBarSeek: return False def getLower(self, n, lst): - lst = lst+[] + lst = lst[:] lst.reverse() for x in lst: if x < n: @@ -1020,11 +1022,12 @@ class InfoBarSeek: from Screens.PVRState import PVRState, TimeshiftState class InfoBarPVRState: - def __init__(self, screen=PVRState): + def __init__(self, screen=PVRState, force_show = False): self.onPlayStateChanged.append(self.__playStateChanged) self.pvrStateDialog = self.session.instantiateDialog(screen) self.onShow.append(self._mayShow) self.onHide.append(self.pvrStateDialog.hide) + self.force_show = force_show def _mayShow(self): if self.execing and self.seekstate != self.SEEK_STATE_PLAY: @@ -1035,7 +1038,7 @@ class InfoBarPVRState: self.pvrStateDialog["state"].setText(playstateString) # if we return into "PLAY" state, ensure that the dialog gets hidden if there will be no infobar displayed - if not config.usage.show_infobar_on_skip.value and self.seekstate == self.SEEK_STATE_PLAY: + if not config.usage.show_infobar_on_skip.value and self.seekstate == self.SEEK_STATE_PLAY and not self.force_show: self.pvrStateDialog.hide() else: self._mayShow() @@ -1043,7 +1046,7 @@ class InfoBarPVRState: class InfoBarTimeshiftState(InfoBarPVRState): def __init__(self): - InfoBarPVRState.__init__(self, screen=TimeshiftState) + InfoBarPVRState.__init__(self, screen=TimeshiftState, force_show = True) def _mayShow(self): if self.execing and self.timeshift_enabled and self.seekstate != self.SEEK_STATE_PLAY: @@ -1278,8 +1281,8 @@ class InfoBarExtensions: extensionsList.remove(extension) else: extensionsList.remove(extension) - for x in extensionsList: - list.append((x[0](), x)) + list.extend([(x[0](), x) for x in extensionsList]) + keys += [""] * len(extensionsList) self.session.openWithCallback(self.extensionCallback, ChoiceBox, title=_("Please choose an extension..."), list = list, keys = keys) @@ -1299,10 +1302,7 @@ class InfoBarPlugins: return name def getPluginList(self): - list = [] - for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EXTENSIONSMENU): - list.append(((boundFunction(self.getPluginName, p.name), boundFunction(self.runPlugin, p), lambda: True), None)) - return list + return [((boundFunction(self.getPluginName, p.name), boundFunction(self.runPlugin, p), lambda: True), None) for p in plugins.getPlugins(where = PluginDescriptor.WHERE_EXTENSIONSMENU)] def runPlugin(self, plugin): if isinstance(self, InfoBarChannelSelection): @@ -1316,10 +1316,7 @@ class InfoBarJobman: self.addExtension(extension = self.getJobList, type = InfoBarExtensions.EXTENSION_LIST) def getJobList(self): - list = [] - for job in job_manager.getPendingJobs(): - list.append(((boundFunction(self.getJobName, job), boundFunction(self.showJobView, job), lambda: True), None)) - return list + return [((boundFunction(self.getJobName, job), boundFunction(self.showJobView, job), lambda: True), None) for job in job_manager.getPendingJobs()] def getJobName(self, job): return "%s: %s (%d%%)" % (job.getStatustext(), job.name, int(100*job.progress/float(job.end))) @@ -1477,7 +1474,7 @@ class InfoBarInstantRecord: simulTimerList = self.session.nav.RecordTimer.record(recording) if simulTimerList is not None: # conflict with other recording name = simulTimerList[1].name - name_date = name + strftime(" %c", localtime(simulTimerList[1].begin)) + name_date = ' '.join((name, strftime('%c', localtime(simulTimerList[1].begin)))) print "[TIMER] conflicts with", name_date recording.autoincrease = True # start with max available length, then increment if recording.setAutoincreaseEnd(): @@ -1559,10 +1556,11 @@ class InfoBarInstantRecord: def inputCallback(self, value): if value is not None: print "stopping recording after", int(value), "minutes." + entry = self.recording[self.selectedEntry] if int(value) != 0: - self.recording[self.selectedEntry].autoincrease = False - self.recording[self.selectedEntry].end = int(time()) + 60 * int(value) - self.session.nav.RecordTimer.timeChanged(self.recording[self.selectedEntry]) + entry.autoincrease = False + entry.end = int(time()) + 60 * int(value) + self.session.nav.RecordTimer.timeChanged(entry) def instantRecord(self): dir = config.movielist.last_videodir.value @@ -1578,22 +1576,22 @@ class InfoBarInstantRecord: if self.isInstantRecordRunning(): self.session.openWithCallback(self.recordQuestionCallback, ChoiceBox, \ title=_("A recording is currently running.\nWhat do you want to do?"), \ - list=[(_("add recording (stop after current event)"), "event"), \ + list=((_("add recording (stop after current event)"), "event"), \ (_("add recording (enter recording duration)"), "manualduration"), \ (_("add recording (enter recording endtime)"), "manualendtime"), \ (_("add recording (indefinitely)"), "indefinitely"), \ (_("change recording (duration)"), "changeduration"), \ (_("change recording (endtime)"), "changeendtime"), \ (_("stop recording"), "stop"), \ - (_("do nothing"), "no")]) + (_("do nothing"), "no"))) else: self.session.openWithCallback(self.recordQuestionCallback, ChoiceBox, \ title=_("Start recording?"), \ - list=[(_("add recording (stop after current event)"), "event"), \ + list=((_("add recording (stop after current event)"), "event"), \ (_("add recording (enter recording duration)"), "manualduration"), \ (_("add recording (enter recording endtime)"), "manualendtime"), \ (_("add recording (indefinitely)"), "indefinitely"), \ - (_("don't record"), "no")]) + (_("don't record"), "no"))) from Tools.ISO639 import LanguageCodes @@ -1612,8 +1610,9 @@ class InfoBarAudioSelection: if n > 0: self.audioChannel = service.audioChannel() - for x in range(n): - i = audio.getTrackInfo(x) + idx = 0 + while idx < n: + i = audio.getTrackInfo(idx) language = i.getLanguage() description = i.getDescription() @@ -1625,7 +1624,8 @@ class InfoBarAudioSelection: else: description = language - tlist.append((description, x)) + tlist.append((description, idx)) + idx += 1 tlist.sort(key=lambda x: x[0]) @@ -1672,7 +1672,7 @@ class InfoBarAudioSelection: if audio[1] == "mode": keys = ["red", "green", "yellow"] selection = self.audioChannel.getCurrentChannel() - tlist = [(_("left"), 0), (_("stereo"), 1), (_("right"), 2)] + tlist = ((_("left"), 0), (_("stereo"), 1), (_("right"), 2)) self.session.openWithCallback(self.modeSelected, ChoiceBox, title=_("Select audio mode"), list = tlist, selection = selection, keys = keys) else: del self.audioChannel @@ -1727,9 +1727,12 @@ class InfoBarSubserviceSelection: if n and n > 0: selection = -1 ref = self.session.nav.getCurrentlyPlayingServiceReference() - for x in range(n): - if subservices.getSubservice(x).toString() == ref.toString(): - selection = x + idx = 0 + while idx < n: + if subservices.getSubservice(idx).toString() == ref.toString(): + selection = idx + break + idx += 1 if selection != -1: selection += direction if selection >= n: @@ -1751,11 +1754,13 @@ class InfoBarSubserviceSelection: if n and n > 0: ref = self.session.nav.getCurrentlyPlayingServiceReference() tlist = [] - for x in range(n): - i = subservices.getSubservice(x) + idx = 0 + while idx < n: + i = subservices.getSubservice(idx) if i.toString() == ref.toString(): - selection = x + selection = idx tlist.append((i.getName(), i)) + idx += 1 if self.bouquets and len(self.bouquets): keys = ["red", "blue", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ] + [""] * n @@ -1832,10 +1837,11 @@ class InfoBarNotifications: self.checkNotifications() def checkNotifications(self): - if len(Notifications.notifications): - n = Notifications.notifications[0] + notifications = Notifications.notifications + if notifications: + n = notifications[0] - Notifications.notifications = Notifications.notifications[1:] + del notifications[0] cb = n[0] if n[3].has_key("onSessionOpenCallback"): @@ -1988,7 +1994,7 @@ class InfoBarCueSheetSupport: if bestdiff >= 0: nearest = [0, False] for cp in self.cut_list: - if beforecut and cp[1] in [self.CUT_TYPE_IN, self.CUT_TYPE_OUT]: + if beforecut and cp[1] in (self.CUT_TYPE_IN, self.CUT_TYPE_OUT): beforecut = False if cp[1] == self.CUT_TYPE_IN: # Start is here, disregard previous marks diff = cmp(cp[0] - pts) @@ -1997,7 +2003,7 @@ class InfoBarCueSheetSupport: bestdiff = diff else: nearest = None - if cp[1] in [self.CUT_TYPE_MARK, self.CUT_TYPE_LAST]: + if cp[1] in (self.CUT_TYPE_MARK, self.CUT_TYPE_LAST): diff = cmp(cp[0] - pts) if diff >= 0 and (nearest is None or bestdiff > diff): nearest = cp diff --git a/lib/python/Screens/LocationBox.py b/lib/python/Screens/LocationBox.py index 68d4f772..389d3624 100644 --- a/lib/python/Screens/LocationBox.py +++ b/lib/python/Screens/LocationBox.py @@ -326,7 +326,7 @@ class LocationBox(Screen, NumericalTextInput, HelpableScreen): def selectConfirmed(self, ret): if ret: - ret = ''.join([self.getPreferredFolder(), self.filename]) + ret = ''.join((self.getPreferredFolder(), self.filename)) if self.realBookmarks: if self.autoAdd and not ret in self.bookmarks: self.bookmarks.append(self.getPreferredFolder()) @@ -390,23 +390,28 @@ class LocationBox(Screen, NumericalTextInput, HelpableScreen): # Write Combination of Folder & Filename when Folder is valid currFolder = self.getPreferredFolder() if currFolder is not None: - self["target"].setText(''.join([currFolder, self.filename])) + self["target"].setText(''.join((currFolder, self.filename))) # Display a Warning otherwise else: self["target"].setText(_("Invalid Location")) def showMenu(self): if not self.userMode and self.realBookmarks: - menu = [] if self.currList == "filelist": - menu.append((_("switch to bookmarks"), self.switchToBookList)) - menu.append((_("add bookmark"), self.addRemoveBookmark)) + menu = [ + (_("switch to bookmarks"), self.switchToBookList), + (_("add bookmark"), self.addRemoveBookmark) + ] if self.editDir: - menu.append((_("create directory"), self.createDir)) - menu.append((_("remove directory"), self.removeDir)) + menu.extend(( + (_("create directory"), self.createDir), + (_("remove directory"), self.removeDir) + )) else: - menu.append((_("switch to filelist"), self.switchToFileList)) - menu.append((_("remove bookmark"), self.addRemoveBookmark)) + menu = ( + (_("switch to filelist"), self.switchToFileList) + (_("remove bookmark"), self.addRemoveBookmark) + ) self.session.openWithCallback( self.menuCallback, diff --git a/lib/python/Screens/PluginBrowser.py b/lib/python/Screens/PluginBrowser.py index 520d6d7a..0f6ee746 100644 --- a/lib/python/Screens/PluginBrowser.py +++ b/lib/python/Screens/PluginBrowser.py @@ -106,17 +106,18 @@ class PluginDownloadBrowser(Screen): if sel is None: return - if type(sel[0]) is str: # category - if sel[0] in self.expanded: - self.expanded.remove(sel[0]) + sel = sel[0] + if isinstance(sel, str): # category + if sel in self.expanded: + self.expanded.remove(sel) else: - self.expanded.append(sel[0]) + self.expanded.append(sel) self.updateList() else: if self.type == self.DOWNLOAD: - self.session.openWithCallback(self.runInstall, MessageBox, _("Do you really want to download\nthe plugin \"%s\"?") % sel[0].name) + self.session.openWithCallback(self.runInstall, MessageBox, _("Do you really want to download\nthe plugin \"%s\"?") % sel.name) elif self.type == self.REMOVE: - self.session.openWithCallback(self.runInstall, MessageBox, _("Do you really want to REMOVE\nthe plugin \"%s\"?") % sel[0].name) + self.session.openWithCallback(self.runInstall, MessageBox, _("Do you really want to REMOVE\nthe plugin \"%s\"?") % sel.name) def runInstall(self, val): if val: diff --git a/lib/python/Screens/ServiceInfo.py b/lib/python/Screens/ServiceInfo.py index e07b3208..df8af4b4 100644 --- a/lib/python/Screens/ServiceInfo.py +++ b/lib/python/Screens/ServiceInfo.py @@ -25,7 +25,7 @@ def ServiceInfoListEntry(a, b, valueType=TYPE_TEXT, param=4): 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 type(b) is not str: + if not isinstance(b, str): if valueType == TYPE_VALUE_HEX: b = ("0x%0" + str(param) + "x") % to_unsigned(b) elif valueType == TYPE_VALUE_DEC: diff --git a/lib/python/Screens/TimerEdit.py b/lib/python/Screens/TimerEdit.py index bb2d3c76..cdff4c5b 100644 --- a/lib/python/Screens/TimerEdit.py +++ b/lib/python/Screens/TimerEdit.py @@ -95,10 +95,11 @@ class TimerEditList(Screen): else: if t.isRunning(): if t.repeated: - list = [] - list.append((_("Stop current event but not coming events"), "stoponlycurrent")) - list.append((_("Stop current event and disable coming events"), "stopall")) - list.append((_("Don't stop current event but disable coming events"), "stoponlycoming")) + list = ( + (_("Stop current event but not coming events"), "stoponlycurrent"), + (_("Stop current event and disable coming events"), "stopall"), + (_("Don't stop current event but disable coming events"), "stoponlycoming") + ) self.session.openWithCallback(boundFunction(self.runningEventCallback, t), ChoiceBox, title=_("Repeating event currently recording... What do you want to do?"), list = list) else: t.disable() diff --git a/lib/python/Screens/TimerEntry.py b/lib/python/Screens/TimerEntry.py index 0544eff1..92a16af8 100644 --- a/lib/python/Screens/TimerEntry.py +++ b/lib/python/Screens/TimerEntry.py @@ -97,7 +97,7 @@ class TimerEntry(Screen, ConfigListScreen): self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type) 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_tags = self.timer.tags[:] self.timerentry_tagsset = ConfigSelection(choices = [len(self.timerentry_tags) == 0 and "None" or " ".join(self.timerentry_tags)]) self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))]) diff --git a/lib/python/Screens/Wizard.py b/lib/python/Screens/Wizard.py index feba8ac2..2326b915 100755 --- a/lib/python/Screens/Wizard.py +++ b/lib/python/Screens/Wizard.py @@ -1,7 +1,5 @@ from Screen import Screen -import string - from Screens.HelpMenu import HelpableScreen from Components.config import config, KEY_LEFT, KEY_RIGHT, KEY_HOME, KEY_END, KEY_0, KEY_DELETE, KEY_BACKSPACE, KEY_OK, KEY_TOGGLEOW, KEY_ASCII, KEY_TIMEOUT, KEY_NUMBERS @@ -87,9 +85,9 @@ class Wizard(Screen): timeoutstep = '' self.wizard[self.lastStep] = {"id": id, "condition": "", "text": "", "timeout": timeout, "timeoutaction": timeoutaction, "timeoutstep": timeoutstep, "list": [], "config": {"screen": None, "args": None, "type": "" }, "code": "", "codeafter": "", "code_async": "", "codeafter_async": "", "nextstep": nextstep} elif (name == "text"): - self.wizard[self.lastStep]["text"] = string.replace(str(attrs.get('value')), "\\n", "\n") + self.wizard[self.lastStep]["text"] = str(attrs.get('value')).replace("\\n", "\n") elif (name == "displaytext"): - self.wizard[self.lastStep]["displaytext"] = string.replace(str(attrs.get('value')), "\\n", "\n") + self.wizard[self.lastStep]["displaytext"] = str(attrs.get('value')).replace("\\n", "\n") elif (name == "list"): if (attrs.has_key('type')): if attrs["type"] == "dynamic": |
