elif event == iRecordableService.evStart:
text = _("A record has been started:\n%s") % self.name
if self.dirnameHadToFallback:
- text = '\n'.join([text, _("Please note that the previously selected media could not be accessed and therefore the default directory is being used instead.")])
+ text = '\n'.join((text, _("Please note that the previously selected media could not be accessed and therefore the default directory is being used instead.")))
# maybe this should be configurable?
Notifications.AddPopup(text = text, type = MessageBox.TYPE_INFO, timeout = 3)
chktimecmp = chktime.tm_wday * 1440 + chktime.tm_hour * 60 + chktime.tm_min
chktimecmp_end = chktimecmp + (duration / 60)
time = localtime(x.begin)
- for y in range(7):
+ for y in (0, 1, 2, 3, 4, 5, 6):
if x.repeated & (2 ** y):
timecmp = y * 1440 + time.tm_hour * 60 + time.tm_min
if timecmp <= chktimecmp < (timecmp + ((x.end - x.begin) / 60)):
month = version[8:10]
day = version[10:12]
- return '-'.join(["dev", year, month, day])
+ return '-'.join(("dev", year, month, day))
file.close()
except IOError:
pass
class NumberActionMap(ActionMap):
def action(self, contexts, action):
- numbers = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
+ numbers = ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")
if (action in numbers and self.actions.has_key(action)):
res = self.actions[action](int(action))
if res is not None:
adict = { }
for (action, funchelp) in actions.iteritems():
# check if this is a tuple
- if type(funchelp) is type(()):
+ if isinstance(funchelp, tuple):
alist.append((action, funchelp[1]))
adict[action] = funchelp[0]
else:
class EPGList(HTMLComponent, GUIComponent):
def __init__(self, type=EPG_TYPE_SINGLE, selChangedCB=None, timer = None):
- self.days = [ _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun") ]
+ self.days = (_("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat"), _("Sun"))
self.timer = timer
self.onSelChanged = [ ]
if selChangedCB is not None:
GUIComponent.__init__(self)
self.type=type
self.l = eListboxPythonMultiContent()
+ self.l.setFont(0, gFont("Regular", 22))
+ self.l.setFont(1, gFont("Regular", 16))
if type == EPG_TYPE_SINGLE:
self.l.setBuildFunc(self.buildSingleEntry)
elif type == EPG_TYPE_MULTI:
def recalcEntrySize(self):
esize = self.l.getItemSize()
- self.l.setFont(0, gFont("Regular", 22))
- self.l.setFont(1, gFont("Regular", 16))
width = esize.width()
height = esize.height()
if self.type == EPG_TYPE_SINGLE:
r1=self.weekday_rect
r2=self.datetime_rect
r3=self.descr_rect
- res = [ None ] # no private data needed
t = localtime(beginTime)
- res.append((eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width(), r1.height(), 0, RT_HALIGN_RIGHT, self.days[t[6]]))
- res.append((eListboxPythonMultiContent.TYPE_TEXT, r2.left(), r2.top(), r2.width(), r1.height(), 0, RT_HALIGN_RIGHT, "%02d.%02d, %02d:%02d"%(t[2],t[1],t[3],t[4])))
+ res = [
+ None, # no private data needed
+ (eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width(), r1.height(), 0, RT_HALIGN_RIGHT, self.days[t[6]]),
+ (eListboxPythonMultiContent.TYPE_TEXT, r2.left(), r2.top(), r2.width(), r1.height(), 0, RT_HALIGN_RIGHT, "%02d.%02d, %02d:%02d"%(t[2],t[1],t[3],t[4]))
+ ]
if rec:
clock_pic = self.getClockPixmap(service, beginTime, duration, eventId)
- res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, r3.left(), r3.top(), 21, 21, clock_pic))
- res.append((eListboxPythonMultiContent.TYPE_TEXT, r3.left() + 25, r3.top(), r3.width(), r3.height(), 0, RT_HALIGN_LEFT, EventName))
+ res.extend((
+ (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, r3.left(), r3.top(), 21, 21, clock_pic),
+ (eListboxPythonMultiContent.TYPE_TEXT, r3.left() + 25, r3.top(), r3.width(), r3.height(), 0, RT_HALIGN_LEFT, EventName)
+ ))
else:
res.append((eListboxPythonMultiContent.TYPE_TEXT, r3.left(), r3.top(), r3.width(), r3.height(), 0, RT_HALIGN_LEFT, EventName))
return res
r1=self.weekday_rect
r2=self.datetime_rect
r3=self.service_rect
- res = [ None ] # no private data needed
t = localtime(beginTime)
- res.append((eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width(), r1.height(), 0, RT_HALIGN_RIGHT, self.days[t[6]]))
- res.append((eListboxPythonMultiContent.TYPE_TEXT, r2.left(), r2.top(), r2.width(), r1.height(), 0, RT_HALIGN_RIGHT, "%02d.%02d, %02d:%02d"%(t[2],t[1],t[3],t[4])))
+ res = [
+ None, # no private data needed
+ (eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width(), r1.height(), 0, RT_HALIGN_RIGHT, self.days[t[6]]),
+ (eListboxPythonMultiContent.TYPE_TEXT, r2.left(), r2.top(), r2.width(), r1.height(), 0, RT_HALIGN_RIGHT, "%02d.%02d, %02d:%02d"%(t[2],t[1],t[3],t[4]))
+ ]
if rec:
clock_pic = self.getClockPixmap(service, beginTime, duration, eventId)
- res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, r3.left(), r3.top(), 21, 21, clock_pic))
- res.append((eListboxPythonMultiContent.TYPE_TEXT, r3.left() + 25, r3.top(), r3.width(), r3.height(), 0, RT_HALIGN_LEFT, service_name))
+ res.extend((
+ (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, r3.left(), r3.top(), 21, 21, clock_pic),
+ (eListboxPythonMultiContent.TYPE_TEXT, r3.left() + 25, r3.top(), r3.width(), r3.height(), 0, RT_HALIGN_LEFT, service_name)
+ ))
else:
res.append((eListboxPythonMultiContent.TYPE_TEXT, r3.left(), r3.top(), r3.width(), r3.height(), 0, RT_HALIGN_LEFT, service_name))
return res
res = [ None ] # no private data needed
if rec:
clock_pic = self.getClockPixmap(service, begTime, duration, eventId)
- res.append((eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width()-21, r1.height(), 0, RT_HALIGN_LEFT, service_name))
- res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, r1.left()+r1.width()-16, r1.top(), 21, 21, clock_pic))
+ res.extend((
+ (eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width()-21, r1.height(), 0, RT_HALIGN_LEFT, service_name),
+ (eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, r1.left()+r1.width()-16, r1.top(), 21, 21, clock_pic)
+ ))
else:
res.append((eListboxPythonMultiContent.TYPE_TEXT, r1.left(), r1.top(), r1.width(), r1.height(), 0, RT_HALIGN_LEFT, service_name))
if begTime is not None:
end = localtime(begTime+duration)
# print "begin", begin
# print "end", end
- res.append((eListboxPythonMultiContent.TYPE_TEXT, r4.left(), r4.top(), r4.width(), r4.height(), 1, RT_HALIGN_CENTER|RT_VALIGN_CENTER, "%02d.%02d - %02d.%02d"%(begin[3],begin[4],end[3],end[4])));
- res.append((eListboxPythonMultiContent.TYPE_TEXT, r3.left(), r3.top(), r3.width(), r3.height(), 0, RT_HALIGN_LEFT, EventName))
+ res.extend((
+ (eListboxPythonMultiContent.TYPE_TEXT, r4.left(), r4.top(), r4.width(), r4.height(), 1, RT_HALIGN_CENTER|RT_VALIGN_CENTER, "%02d.%02d - %02d.%02d"%(begin[3],begin[4],end[3],end[4])),
+ (eListboxPythonMultiContent.TYPE_TEXT, r3.left(), r3.top(), r3.width(), r3.height(), 0, RT_HALIGN_LEFT, EventName)
+ ))
else:
percent = (nowTime - begTime) * 100 / duration
- res.append((eListboxPythonMultiContent.TYPE_PROGRESS, r2.left(), r2.top(), r2.width(), r2.height(), percent));
- res.append((eListboxPythonMultiContent.TYPE_TEXT, r3.left(), r3.top(), r3.width(), r3.height(), 0, RT_HALIGN_LEFT, EventName))
+ res.extend((
+ (eListboxPythonMultiContent.TYPE_PROGRESS, r2.left(), r2.top(), r2.width(), r2.height(), percent),
+ (eListboxPythonMultiContent.TYPE_TEXT, r3.left(), r3.top(), r3.width(), r3.height(), 0, RT_HALIGN_LEFT, EventName)
+ ))
return res
def queryEPG(self, list, buildFunc=None):
return [ ]
def fillMultiEPG(self, services, stime=-1):
- t = time()
+ #t = time()
test = [ (service.ref.toString(), 0, stime) for service in services ]
test.insert(0, 'X0RIBDTCn')
self.list = self.queryEPG(test)
self.l.setList(self.list)
- print time() - t
+ #print time() - t
self.selectionChanged()
def updateMultiEPG(self, direction):
- t = time()
+ #t = time()
test = [ x[3] and (x[1], direction, x[3]) or (x[1], direction, 0) for x in self.list ]
test.insert(0, 'XRIBDTCn')
tmp = self.queryEPG(test)
self.list[cnt]=(changecount, x[0], x[1], x[2], x[3], x[4], x[5], x[6])
cnt+=1
self.l.setList(self.list)
- print time() - t
+ #print time() - t
self.selectionChanged()
def fillSingleEPG(self, service):
- t = time()
+ #t = time()
test = [ 'RIBDT', (service.ref.toString(), 0, -1, -1) ]
self.list = self.queryEPG(test)
self.l.setList(self.list)
- print time() - t
+ #print time() - t
self.selectionChanged()
def sortSingleEPG(self, type):
- if len(self.list):
+ list = self.list
+ if list:
+ event_id = self.getSelectedEventId()
if type == 1:
- event_id = self.getSelectedEventId()
- self.list.sort(key=lambda x: (x[4] and x[4].lower(), x[2]))
- self.l.setList(self.list)
- self.moveToEventId(event_id)
+ list.sort(key=lambda x: (x[4] and x[4].lower(), x[2]))
else:
assert(type == 0)
- event_id = self.getSelectedEventId()
- self.list.sort(key=lambda x: x[2])
- self.l.setList(self.list)
- self.moveToEventId(event_id)
+ list.sort(key=lambda x: x[2])
+ self.moveToEventId(event_id)
def getSelectedEventId(self):
x = self.l.getCurrentSelection()
return x and x[1]
def moveToService(self,serviceref):
- for x in range(len(self.list)):
- if self.list[x][1] == serviceref.toString():
- self.instance.moveSelectionTo(x)
+ index = 0
+ refstr = serviceref.toString()
+ for x in self.list:
+ if x[1] == refstr:
+ self.instance.moveSelectionTo(index)
break
+ index += 1
def moveToEventId(self, eventId):
index = 0
from Tools.Directories import SCOPE_HDD, resolveFilename
from Tools.CList import CList
from SystemInfo import SystemInfo
-import string, time
+import time
from Components.Console import Console
def tryOpen(filename):
# see if this is a harddrive
l = len(device)
- if l and device[l-1] not in string.digits:
+ if l and not device[l-1].isdigit():
error, blacklisted, removable, is_cdrom, partitions, medium_found = self.getBlockDevInfo(device)
if not blacklisted and not removable and not is_cdrom and medium_found:
self.hdd.append(Harddisk(device))
self.partitions.remove(x)
self.on_partition_list_change("remove", x)
l = len(device)
- if l and device[l-1] not in string.digits:
+ if l and not device[l-1].isdigit():
idx = 0
for hdd in self.hdd:
if hdd.device == device:
dev = devname[:3]
part = devname[3:]
for p in part:
- if p not in string.digits:
+ if not p.isdigit():
return devname, 0
return dev, part and int(part) or 0
entry.append( (actionmap, context, action, name ) )
- if type(help).__name__== 'list':
+ if isinstance(help, list):
self.extendedHelp = True
print "extendedHelpEntry found"
entry.append( (eListboxPythonMultiContent.TYPE_TEXT, 0, 0, 400, 26, 0, 0, help[0]) )
continue
# allow single entry not to be a list
- if type(plugins) is not list:
+ if not isinstance(plugins, list):
plugins = [ plugins ]
for p in plugins:
def getPlugins(self, where):
"""Get list of plugins in a specific category"""
- if type(where) is not list:
+ if not isinstance(where, list):
where = [ where ]
res = [ ]
from Components.PluginComponent import plugins
from os import path as os_path, walk as os_walk
-from string import lower
-from mimetypes import guess_type
+from mimetypes import guess_type, add_type
-def getExtension(file):
- p = file.rfind('.')
- if p == -1:
- ext = ""
- else:
- ext = file[p+1:]
-
- return lower(ext)
+add_type("application/x-debian-package", ".ipk")
+add_type("application/ogg", ".ogg")
+add_type("audio/x-flac", ".flac")
+add_type("application/x-dream-package", ".dmpkg")
+add_type("application/x-dream-image", ".nfi")
+add_type("video/MP2T", ".ts")
+add_type("video/x-dvd-iso", ".iso")
def getType(file):
(type, _) = guess_type(file)
if type is None:
- # Detect some mimetypes unknown to dm7025
- # TODO: do mimetypes.add_type once should be better
- ext = getExtension(file)
- if ext == "ipk":
- return "application/x-debian-package"
- elif ext == "ogg":
- return "application/ogg"
- elif ext == "flac":
- return "audio/x-flac"
- elif ext == "dmpkg":
- return "application/x-dream-package"
- elif ext == "nfi":
- return "application/x-dream-image"
- elif ext == "ts":
- return "video/MP2T"
- elif ext == "iso":
- return "video/x-dvd-iso"
- elif file[-12:].lower() == "video_ts.ifo":
+ # Detect some unknown types
+ if file[-12:].lower() == "video_ts.ifo":
return "video/x-dvd"
- elif ext == "dat" and file[-11:-6].lower() == "avseq":
+
+ p = file.rfind('.')
+ if p == -1:
+ return None
+ ext = file[p+1:].lower()
+
+ if ext == "dat" and file[-11:-6].lower() == "avseq":
return "video/x-vcd"
return type
from enigma import eListboxServiceContent, eListbox, eServiceCenter, eServiceReference, gFont, eRect
from Tools.LoadPixmap import LoadPixmap
-from string import upper
-
from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
class ServiceList(HTMLComponent, GUIComponent):
# TODO fill with life
print "Next char: "
index = self.l.getNextBeginningWithChar(char)
- indexup = self.l.getNextBeginningWithChar(upper(char))
+ indexup = self.l.getNextBeginningWithChar(char.upper())
if indexup != 0:
if (index > indexup or index == 0):
index = indexup
if timer.repeated:
flags = timer.repeated
count = 0
- for x in range(0, 7):
+ for x in (0, 1, 2, 3, 4, 5, 6):
if (flags & 1 == 1):
if (count != 0):
repeatedtext += ", "
if timer.begin == self.newtimer.begin:
getUnsignedDataRef1 = timer.service_ref.ref.getUnsignedData
getUnsignedDataRef2 = self.newtimer.service_ref.ref.getUnsignedData
- for x in range(1,5):
+ for x in (1, 2, 3, 4):
if getUnsignedDataRef1(x) != getUnsignedDataRef2(x):
break;
else:
defval = None
val = int(sel.value)
if not val in choices:
- tmp = choices+[]
+ tmp = choices[:]
tmp.reverse()
for x in tmp:
if x < val:
return title
def saveProject(self, path):
- import xml.dom.minidom
- from Tools.XMLTools import elementsWithTag, mergeText, stringToXML
+ from Tools.XMLTools import stringToXML
list = []
list.append('<?xml version="1.0" encoding="utf-8" ?>\n')
list.append('<DreamDVDBurnerProject>\n')
def __init__(self, name = "Plugin", where = [ ], description = "", icon = None, fnc = None, wakeupfnc = None, internal = False):
self.name = name
self.internal = internal
- if type(where) is list:
+ if isinstance(where, list):
self.where = where
else:
self.where = [ where ]
self.description = description
- if type(icon) is str or icon is None:
+ if icon is None or isinstance(icon, str):
self.iconstr = icon
self.icon = None
else:
self.__call__ = fnc
def updateIcon(self, path):
- if type(self.iconstr) is str:
- self.icon = LoadPixmap(path + "/" + self.iconstr)
+ if isinstance(self.iconstr, str):
+ self.icon = LoadPixmap('/'.join((path, self.iconstr)))
else:
self.icon = None
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)
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":
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:
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:
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"""
return False
def getLower(self, n, lst):
- lst = lst+[]
+ lst = lst[:]
lst.reverse()
for x in lst:
if x < n:
oldstate = self.seekstate
self.seekstate = state
- for i in range(3):
+ for i in (0, 1, 2):
if oldstate[i] != self.seekstate[i]:
(self.session.nav.pause, pauseable.setFastForward, pauseable.setSlowMotion)[i](self.seekstate[i])
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)
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):
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)))
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():
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
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
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()
else:
description = language
- tlist.append((description, x))
+ tlist.append((description, idx))
+ idx += 1
tlist.sort(key=lambda x: x[0])
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
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:
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
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"):
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)
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
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())
# 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,
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:
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:
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()
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"))])
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
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":
filename += c
if dirname is not None:
- filename = ''.join([dirname, filename])
+ filename = ''.join((dirname, filename))
i = 0
while True:
class EnigmaOutput:
def write(self, data):
- if type(data) is unicode:
+ if isinstance(data, unicode):
data = data.encode("UTF-8")
ePythonOutput(data)
from Tools.Import import my_import
from Tools.LoadPixmap import LoadPixmap
-from Tools.XMLTools import mergeText
-
colorNames = dict()
def dump(x, i=0):
ctype = converter.get('type')
assert ctype, "'convert'-tag needs a 'type'-attribute"
#print "Converter:", ctype
- #parms = mergeText(converter.childNodes).strip()
try:
parms = converter.text.strip()
except:
parms = ""
- #print "Params:", ctype
- converter_class = my_import('.'.join(["Components", "Converter", ctype])).__dict__.get(ctype)
+ #print "Params:", parms
+ converter_class = my_import('.'.join(("Components", "Converter", ctype))).__dict__.get(ctype)
c = None
source = c
- renderer_class = my_import('.'.join(["Components", "Renderer", wrender])).__dict__.get(wrender)
+ renderer_class = my_import('.'.join(("Components", "Renderer", wrender))).__dict__.get(wrender)
renderer = renderer_class() # instantiate renderer
day = []
flags = self.repeated
- for x in range(0, 7):
+ for x in (0, 1, 2, 3, 4, 5, 6):
if (flags & 1 == 1):
day.append(0)
print "Day: " + str(x)