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"
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"):
@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
@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:
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
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:
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
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)
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
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:
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):
# "+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
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":
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
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:
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 ""
("/", _("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
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
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
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) )
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):
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
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)
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
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]
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":
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, ""))))
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
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
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 = [ ]
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):
# 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
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)
# ...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)
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
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] ]
+
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))
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
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
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"
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
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):
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):
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))
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))
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))
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()
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:
return key
return "nolang"
-languageChoices = LanguageChoices()
\ No newline at end of file
+languageChoices = LanguageChoices()
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") ]
ScanPath(path = "", with_subdirs = False),
],
name = "DVD",
- description = "Play DVD",
+ description = _("Play DVD"),
openfnc = filescan_open,
)]
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)]
ScanPath(path = "", with_subdirs = False),
],
name = "Movie",
- description = "View Movies...",
+ description = _("View Movies..."),
openfnc = filescan_open,
),
Scanner(mimetypes = ["video/x-vcd"],
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"],
ScanPath(path = "", with_subdirs = False),
],
name = "Music",
- description = "Play Music...",
+ description = _("Play Music..."),
openfnc = filescan_open,
)]
try:
ScanPath(path = "", with_subdirs = False),
],
name = "Audio-CD",
- description = "Play Audio-CD...",
+ description = _("Play Audio-CD..."),
openfnc = audioCD_open,
))
return mediatypes
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):
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)
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)
ScanPath(path = "", with_subdirs = False),
],
name = "Pictures",
- description = "View Photos...",
+ description = _("View Photos..."),
openfnc = filescan_open,
)
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) ]
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":
def runAsync(self, finished_cb):
self.finished_cb = finished_cb
self.doRestore()
-
-
\ No newline at end of file
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:
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
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:
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:
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))
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:
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:
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:
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()
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
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)
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
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)
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()
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()
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()
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
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()
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()
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()
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()
</screen>"""
def __init__(self, session, title = "Console", cmdlist = None, finishedCallback = None, closeOnSuccess = False):
- self.skin = Console.skin
Screen.__init__(self, session)
self.finishedCallback = finishedCallback
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)
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 =
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"
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"],
{
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()
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)
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:
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
#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:
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)
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)
})
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 """
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))
self.bouquetSel.up()
bouquet = self.bouquetSel.getCurrent()
services = self.getBouquetServices(bouquet)
- if len(services):
+ if services:
self.epg_bouquet = bouquet
epg.setServices(services)
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:
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()
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:
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)
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
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)
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
# <convert type="ServiceName">Reference</convert>
# </widget>
- def __init__(self, session, parent):
- Screen.__init__(self, session, parent = parent)
-
class InfoBarSummarySupport:
def __init__(self):
pass
</widget>
</screen>"""
- def __init__(self, session, parent):
- Screen.__init__(self, session)
-
class InfoBarMoviePlayerSummarySupport:
def __init__(self):
pass
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)"),
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")
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):
})
# Run some functions when shown
- self.onShown.extend([
+ self.onShown.extend((
boundFunction(self.setTitle, windowTitle),
self.updateTarget,
self.showHideRename,
- ])
+ ))
self.onLayoutFinish.append(self.switchToFileListOnStart)
)
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):
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
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__(
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()
</widget>
</screen>"""
- def __init__(self, session, parent):
- Screen.__init__(self, session, parent)
-
class Menu(Screen):
ALLOW_SUSPEND = True
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):
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)
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()
})
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:
from Screen import Screen
class Mute(Screen):
- def __init__(self, session):
- Screen.__init__(self, session)
+ pass
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:
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",
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)
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
self["state"] = Label(text="")
class TimeshiftState(PVRState):
- def __init__(self, session):
- PVRState.__init__(self, session)
+ pass
+
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()
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):
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"))
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)
for selectPic in self.selectpics:
for pic in selectPic[1]:
self[pic].hide()
-
\ No newline at end of file
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))
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)
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)
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]
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":
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)
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:
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):
"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):
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),
("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),
("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),
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 = """
</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)
</widget>
</screen>"""
- def __init__(self, session, parent):
- Screen.__init__(self, session)
-
from enigma import quitMainloop, iRecordableService
from Screens.MessageBox import MessageBox
from time import time
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 = ""
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
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()
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):
from Screens.Screen import Screen
class SubtitleDisplay(Screen):
- def __init__(self, session):
- Screen.__init__(self, session)
-
+ pass
+
# not really much to do...
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
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()
ConfigListScreen.keyRight(self)
def ok(self):
- if len(self.list):
+ if self.list:
cur = self["config"].getCurrent()
self.enableSubtitle(cur[2])
self.close(1)
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:
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()
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)
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()
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"
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
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"))])
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
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)
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)
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)
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):
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 = []
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("")
def selected(self):
self.close(self["timerlist"].getCurrentIndex())
-
\ No newline at end of file
-# -*- coding: iso-8859-1 -*-\r
-from Components.Language import language\r
-from Components.ActionMap import ActionMap\r
-from Components.Label import Label\r
-from Components.Pixmap import Pixmap\r
-from Components.MenuList import MenuList\r
-from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest\r
-from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_CENTER, RT_VALIGN_CENTER\r
-from Screen import Screen\r
-from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE\r
-from Tools.LoadPixmap import LoadPixmap\r
-\r
-class VirtualKeyBoardList(MenuList):\r
- def __init__(self, list, enableWrapAround=False):\r
- MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)\r
- self.l.setFont(0, gFont("Regular", 22))\r
- self.l.setItemHeight(45)\r
-\r
-def VirtualKeyBoardEntryComponent(keys, selectedKey,shiftMode=False):\r
- key_backspace = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_backspace.png"))\r
- key_bg = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_bg.png"))\r
- key_clr = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_clr.png"))\r
- key_esc = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_esc.png"))\r
- key_ok = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_ok.png"))\r
- key_sel = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_sel.png"))\r
- key_shift = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_shift.png"))\r
- key_shift_sel = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_shift_sel.png"))\r
- key_space = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_space.png"))\r
- \r
- res = [ (keys) ]\r
- \r
- x = 0\r
- count = 0\r
- if shiftMode:\r
- shiftkey_png = key_shift_sel\r
- else:\r
- shiftkey_png = key_shift\r
- for key in keys:\r
- if key == "EXIT":\r
- res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_esc))\r
- elif key == "BACKSPACE":\r
- res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_backspace))\r
- elif key == "CLEAR":\r
- res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_clr))\r
- elif key == "SHIFT":\r
- res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=shiftkey_png))\r
- elif key == "SPACE":\r
- res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_space))\r
- elif key == "OK":\r
- res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_ok))\r
- #elif key == "<-":\r
- # res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_left))\r
- #elif key == "->":\r
- # res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_right))\r
- \r
- else:\r
- res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_bg))\r
- res.append(MultiContentEntryText(pos=(x, 0), size=(45, 45), font=0, text=key.encode("utf-8"), flags=RT_HALIGN_CENTER | RT_VALIGN_CENTER))\r
- \r
- if selectedKey == count:\r
- res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_sel))\r
- \r
- x += 45\r
- count += 1\r
- \r
- return res\r
-\r
-\r
-class VirtualKeyBoard(Screen):\r
-\r
- def __init__(self, session, title="", text=""):\r
- Screen.__init__(self, session)\r
- self.keys_list = []\r
- self.shiftkeys_list = []\r
- self.lang = language.getLanguage()\r
- if self.lang == 'de_DE':\r
- self.keys_list = [\r
- [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],\r
- [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"ü", u"+"],\r
- [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ö", u"ä", u"#"],\r
- [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"],\r
- [u"SHIFT", u"SPACE", u"@", u"ß", u"OK"]]\r
- \r
- self.shiftkeys_list = [\r
- [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],\r
- [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"Ü", u"*"],\r
- [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ö", u"Ä", u"'"],\r
- [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],\r
- [u"SHIFT", u"SPACE", u"?", u"\\", u"OK"]]\r
- \r
- elif self.lang == 'es_ES':\r
- #still missing keys (u"ùÙ")\r
- self.keys_list = [\r
- [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],\r
- [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"ú", u"+"],\r
- [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ó", u"á", u"#"],\r
- [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"],\r
- [u"SHIFT", u"SPACE", u"@", u"£", u"à", u"é", u"è", u"í", u"ì", u"ñ", u"ò", u"OK"]]\r
- \r
- self.shiftkeys_list = [\r
- [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],\r
- [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"Ú", u"*"],\r
- [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ó", u"Á", u"'"],\r
- [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],\r
- [u"SHIFT", u"SPACE", u"?", u"\\", u"À", u"É", u"È", u"Í", u"Ì", u"Ñ", u"Ò", u"OK"]]\r
- \r
- elif self.lang in ['sv_SE', 'fi_FI']:\r
- self.keys_list = [\r
- [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],\r
- [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"é", u"+"],\r
- [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ö", u"ä", u"#"],\r
- [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"],\r
- [u"SHIFT", u"SPACE", u"@", u"ß", u"å", u"OK"]]\r
- \r
- self.shiftkeys_list = [\r
- [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],\r
- [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"É", u"*"],\r
- [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ö", u"Ä", u"'"],\r
- [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],\r
-\r
- [u"SHIFT", u"SPACE", u"?", u"\\", u"Å", u"OK"]]\r
- else:\r
- self.keys_list = [\r
- [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],\r
- [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"+", u"@"],\r
- [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"#", u"\\"],\r
- [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"],\r
- [u"SHIFT", u"SPACE", u"OK"]]\r
- \r
- self.shiftkeys_list = [\r
- [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],\r
- [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"*"],\r
- [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"'", u"?"],\r
- [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],\r
- [u"SHIFT", u"SPACE", u"OK"]]\r
- \r
- self.shiftMode = False\r
- self.text = text\r
- self.selectedKey = 0\r
- \r
- self["header"] = Label(title)\r
- self["text"] = Label(self.text)\r
- self["list"] = VirtualKeyBoardList([])\r
- \r
- self["actions"] = ActionMap(["OkCancelActions", "WizardActions", "ColorActions"],\r
- {\r
- "ok": self.okClicked,\r
- "cancel": self.exit,\r
- "left": self.left,\r
- "right": self.right,\r
- "up": self.up,\r
- "down": self.down,\r
- "red": self.backClicked,\r
- "green": self.ok\r
- }, -2)\r
- \r
- self.onLayoutFinish.append(self.buildVirtualKeyBoard)\r
-\r
- def buildVirtualKeyBoard(self, selectedKey=0):\r
- list = []\r
- \r
- if self.shiftMode:\r
- self.k_list = self.shiftkeys_list\r
- for keys in self.k_list:\r
- if selectedKey < 12 and selectedKey > -1:\r
- list.append(VirtualKeyBoardEntryComponent(keys, selectedKey,True))\r
- else:\r
- list.append(VirtualKeyBoardEntryComponent(keys, -1,True))\r
- selectedKey -= 12\r
- else:\r
- self.k_list = self.keys_list\r
- for keys in self.k_list:\r
- if selectedKey < 12 and selectedKey > -1:\r
- list.append(VirtualKeyBoardEntryComponent(keys, selectedKey))\r
- else:\r
- list.append(VirtualKeyBoardEntryComponent(keys, -1))\r
- selectedKey -= 12\r
- \r
- self["list"].setList(list)\r
-\r
- \r
- def backClicked(self):\r
- self.text = self["text"].getText()[:-1]\r
- self["text"].setText(self.text)\r
- \r
- def okClicked(self):\r
- if self.shiftMode:\r
- list = self.shiftkeys_list\r
- else:\r
- list = self.keys_list\r
- \r
- selectedKey = self.selectedKey\r
-\r
- for x in list:\r
- if selectedKey < 12:\r
- text = x[selectedKey]\r
- break\r
- else:\r
- selectedKey -= 12\r
-\r
- text = text.encode("utf-8")\r
-\r
- if text == "EXIT":\r
- self.close(None)\r
- \r
- elif text == "BACKSPACE":\r
- self.text = self["text"].getText()[:-1]\r
- self["text"].setText(self.text)\r
- \r
- elif text == "CLEAR":\r
- self.text = ""\r
- self["text"].setText(self.text)\r
- \r
- elif text == "SHIFT":\r
- if self.shiftMode:\r
- self.shiftMode = False\r
- else:\r
- self.shiftMode = True\r
- \r
- self.buildVirtualKeyBoard(self.selectedKey)\r
- \r
- elif text == "SPACE":\r
- self.text += " "\r
- self["text"].setText(self.text)\r
- \r
- elif text == "OK":\r
- self.close(self["text"].getText())\r
- \r
- else:\r
- self.text = self["text"].getText()\r
- self.text += text\r
- self["text"].setText(self.text)\r
-\r
- def ok(self):\r
- self.close(self["text"].getText())\r
-\r
- def exit(self):\r
- self.close(None)\r
-\r
- def left(self):\r
- self.selectedKey -= 1\r
- \r
- if self.selectedKey == -1:\r
- self.selectedKey = 11\r
- elif self.selectedKey == 11:\r
- self.selectedKey = 23\r
- elif self.selectedKey == 23:\r
- self.selectedKey = 35\r
- elif self.selectedKey == 35:\r
- self.selectedKey = 47\r
- elif self.selectedKey == 47:\r
- self.selectedKey = 59\r
- \r
- self.showActiveKey()\r
-\r
- def right(self):\r
- self.selectedKey += 1\r
- \r
- if self.selectedKey == 12:\r
- self.selectedKey = 0\r
- elif self.selectedKey == 24:\r
- self.selectedKey = 12\r
- elif self.selectedKey == 36:\r
- self.selectedKey = 24\r
- elif self.selectedKey == 48:\r
- self.selectedKey = 36\r
- elif self.selectedKey == 60:\r
- self.selectedKey = 48\r
- \r
- self.showActiveKey()\r
-\r
- def up(self):\r
- self.selectedKey -= 12\r
- \r
- if self.selectedKey < 0:\r
- self.selectedKey += 60\r
- \r
- self.showActiveKey()\r
-\r
- def down(self):\r
- self.selectedKey += 12\r
- \r
- if self.selectedKey > 59:\r
- self.selectedKey -= 60\r
- \r
- self.showActiveKey()\r
-\r
- def showActiveKey(self):\r
- self.buildVirtualKeyBoard(self.selectedKey)\r
+# -*- coding: iso-8859-1 -*-
+from Components.Language import language
+from Components.ActionMap import ActionMap
+from Components.Label import Label
+from Components.Pixmap import Pixmap
+from Components.MenuList import MenuList
+from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest
+from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_CENTER, RT_VALIGN_CENTER
+from Screen import Screen
+from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE
+from Tools.LoadPixmap import LoadPixmap
+
+class VirtualKeyBoardList(MenuList):
+ def __init__(self, list, enableWrapAround=False):
+ MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
+ self.l.setFont(0, gFont("Regular", 22))
+ self.l.setItemHeight(45)
+
+def VirtualKeyBoardEntryComponent(keys, selectedKey,shiftMode=False):
+ key_backspace = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_backspace.png"))
+ key_bg = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_bg.png"))
+ key_clr = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_clr.png"))
+ key_esc = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_esc.png"))
+ key_ok = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_ok.png"))
+ key_sel = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_sel.png"))
+ key_shift = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_shift.png"))
+ key_shift_sel = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_shift_sel.png"))
+ key_space = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/vkey_space.png"))
+
+ res = [ (keys) ]
+
+ x = 0
+ count = 0
+ if shiftMode:
+ shiftkey_png = key_shift_sel
+ else:
+ shiftkey_png = key_shift
+ for key in keys:
+ if key == "EXIT":
+ res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_esc))
+ elif key == "BACKSPACE":
+ res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_backspace))
+ elif key == "CLEAR":
+ res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_clr))
+ elif key == "SHIFT":
+ res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=shiftkey_png))
+ elif key == "SPACE":
+ res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_space))
+ elif key == "OK":
+ res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_ok))
+ #elif key == "<-":
+ # res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_left))
+ #elif key == "->":
+ # res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_right))
+
+ else:
+ res.extend((
+ MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_bg),
+ MultiContentEntryText(pos=(x, 0), size=(45, 45), font=0, text=key.encode("utf-8"), flags=RT_HALIGN_CENTER | RT_VALIGN_CENTER)
+ ))
+
+ if selectedKey == count:
+ res.append(MultiContentEntryPixmapAlphaTest(pos=(x, 0), size=(45, 45), png=key_sel))
+
+ x += 45
+ count += 1
+
+ return res
+
+
+class VirtualKeyBoard(Screen):
+
+ def __init__(self, session, title="", text=""):
+ Screen.__init__(self, session)
+ self.keys_list = []
+ self.shiftkeys_list = []
+ self.lang = language.getLanguage()
+ if self.lang == 'de_DE':
+ self.keys_list = [
+ [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
+ [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"ü", u"+"],
+ [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ö", u"ä", u"#"],
+ [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"],
+ [u"SHIFT", u"SPACE", u"@", u"ß", u"OK"]]
+
+ self.shiftkeys_list = [
+ [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],
+ [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"Ü", u"*"],
+ [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ö", u"Ä", u"'"],
+ [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],
+ [u"SHIFT", u"SPACE", u"?", u"\\", u"OK"]]
+
+ elif self.lang == 'es_ES':
+ #still missing keys (u"ùÙ")
+ self.keys_list = [
+ [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
+ [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"ú", u"+"],
+ [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ó", u"á", u"#"],
+ [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"],
+ [u"SHIFT", u"SPACE", u"@", u"£", u"à", u"é", u"è", u"í", u"ì", u"ñ", u"ò", u"OK"]]
+
+ self.shiftkeys_list = [
+ [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],
+ [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"Ú", u"*"],
+ [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ó", u"Á", u"'"],
+ [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],
+ [u"SHIFT", u"SPACE", u"?", u"\\", u"À", u"É", u"È", u"Í", u"Ì", u"Ñ", u"Ò", u"OK"]]
+
+ elif self.lang in ('sv_SE', 'fi_FI'):
+ self.keys_list = [
+ [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
+ [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"é", u"+"],
+ [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"ö", u"ä", u"#"],
+ [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"],
+ [u"SHIFT", u"SPACE", u"@", u"ß", u"å", u"OK"]]
+
+ self.shiftkeys_list = [
+ [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],
+ [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"É", u"*"],
+ [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"Ö", u"Ä", u"'"],
+ [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],
+
+ [u"SHIFT", u"SPACE", u"?", u"\\", u"Å", u"OK"]]
+ else:
+ self.keys_list = [
+ [u"EXIT", u"1", u"2", u"3", u"4", u"5", u"6", u"7", u"8", u"9", u"0", u"BACKSPACE"],
+ [u"q", u"w", u"e", u"r", u"t", u"z", u"u", u"i", u"o", u"p", u"+", u"@"],
+ [u"a", u"s", u"d", u"f", u"g", u"h", u"j", u"k", u"l", u"#", u"\\"],
+ [u"<", u"y", u"x", u"c", u"v", u"b", u"n", u"m", u",", ".", u"-", u"CLEAR"],
+ [u"SHIFT", u"SPACE", u"OK"]]
+
+ self.shiftkeys_list = [
+ [u"EXIT", u"!", u'"', u"§", u"$", u"%", u"&", u"/", u"(", u")", u"=", u"BACKSPACE"],
+ [u"Q", u"W", u"E", u"R", u"T", u"Z", u"U", u"I", u"O", u"P", u"*"],
+ [u"A", u"S", u"D", u"F", u"G", u"H", u"J", u"K", u"L", u"'", u"?"],
+ [u">", u"Y", u"X", u"C", u"V", u"B", u"N", u"M", u";", u":", u"_", u"CLEAR"],
+ [u"SHIFT", u"SPACE", u"OK"]]
+
+ self.shiftMode = False
+ self.text = text
+ self.selectedKey = 0
+
+ self["header"] = Label(title)
+ self["text"] = Label(self.text)
+ self["list"] = VirtualKeyBoardList([])
+
+ self["actions"] = ActionMap(["OkCancelActions", "WizardActions", "ColorActions"],
+ {
+ "ok": self.okClicked,
+ "cancel": self.exit,
+ "left": self.left,
+ "right": self.right,
+ "up": self.up,
+ "down": self.down,
+ "red": self.backClicked,
+ "green": self.ok
+ }, -2)
+
+ self.onLayoutFinish.append(self.buildVirtualKeyBoard)
+
+ def buildVirtualKeyBoard(self, selectedKey=0):
+ list = []
+
+ if self.shiftMode:
+ self.k_list = self.shiftkeys_list
+ for keys in self.k_list:
+ if selectedKey < 12 and selectedKey > -1:
+ list.append(VirtualKeyBoardEntryComponent(keys, selectedKey,True))
+ else:
+ list.append(VirtualKeyBoardEntryComponent(keys, -1,True))
+ selectedKey -= 12
+ else:
+ self.k_list = self.keys_list
+ for keys in self.k_list:
+ if selectedKey < 12 and selectedKey > -1:
+ list.append(VirtualKeyBoardEntryComponent(keys, selectedKey))
+ else:
+ list.append(VirtualKeyBoardEntryComponent(keys, -1))
+ selectedKey -= 12
+
+ self["list"].setList(list)
+
+
+ def backClicked(self):
+ self.text = self["text"].getText()[:-1]
+ self["text"].setText(self.text)
+
+ def okClicked(self):
+ if self.shiftMode:
+ list = self.shiftkeys_list
+ else:
+ list = self.keys_list
+
+ selectedKey = self.selectedKey
+
+ for x in list:
+ if selectedKey < 12:
+ text = x[selectedKey]
+ break
+ else:
+ selectedKey -= 12
+
+ text = text.encode("utf-8")
+
+ if text == "EXIT":
+ self.close(None)
+
+ elif text == "BACKSPACE":
+ self.text = self["text"].getText()[:-1]
+ self["text"].setText(self.text)
+
+ elif text == "CLEAR":
+ self.text = ""
+ self["text"].setText(self.text)
+
+ elif text == "SHIFT":
+ if self.shiftMode:
+ self.shiftMode = False
+ else:
+ self.shiftMode = True
+
+ self.buildVirtualKeyBoard(self.selectedKey)
+
+ elif text == "SPACE":
+ self.text += " "
+ self["text"].setText(self.text)
+
+ elif text == "OK":
+ self.close(self["text"].getText())
+
+ else:
+ self.text = self["text"].getText()
+ self.text += text
+ self["text"].setText(self.text)
+
+ def ok(self):
+ self.close(self["text"].getText())
+
+ def exit(self):
+ self.close(None)
+
+ def left(self):
+ self.selectedKey -= 1
+
+ if self.selectedKey == -1:
+ self.selectedKey = 11
+ elif self.selectedKey == 11:
+ self.selectedKey = 23
+ elif self.selectedKey == 23:
+ self.selectedKey = 35
+ elif self.selectedKey == 35:
+ self.selectedKey = 47
+ elif self.selectedKey == 47:
+ self.selectedKey = 59
+
+ self.showActiveKey()
+
+ def right(self):
+ self.selectedKey += 1
+
+ if self.selectedKey == 12:
+ self.selectedKey = 0
+ elif self.selectedKey == 24:
+ self.selectedKey = 12
+ elif self.selectedKey == 36:
+ self.selectedKey = 24
+ elif self.selectedKey == 48:
+ self.selectedKey = 36
+ elif self.selectedKey == 60:
+ self.selectedKey = 48
+
+ self.showActiveKey()
+
+ def up(self):
+ self.selectedKey -= 12
+
+ if self.selectedKey < 0:
+ self.selectedKey += 60
+
+ self.showActiveKey()
+
+ def down(self):
+ self.selectedKey += 12
+
+ if self.selectedKey > 59:
+ self.selectedKey -= 60
+
+ self.showActiveKey()
+
+ def showActiveKey(self):
+ self.buildVirtualKeyBoard(self.selectedKey)
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()
self.updateText(firstset = True)
self.updateValues()
self.updateLanguageDescription()
-
-
-
-
\ No newline at end of file
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
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:
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.
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()
screen = screensToRun[0][1]
- if len(screensToRun):
+ if screensToRun:
session.openWithCallback(boundFunction(runNextScreen, session, screensToRun[1:]), screen)
else:
session.open(screen)
]
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:
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 = [ ]
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:
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)
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
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])