Skip to content

Commit

Permalink
Use python3 like print function
Browse files Browse the repository at this point in the history
Used:
futurize -w -n -f print_with_import *.py

Is compatible with Python2
  • Loading branch information
Hains committed Mar 20, 2022
1 parent a6e5a55 commit 5161301
Show file tree
Hide file tree
Showing 151 changed files with 1,135 additions and 984 deletions.
17 changes: 9 additions & 8 deletions lib/actions/parseactions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
# takes a header file, outputs action ids

import tokenize
Expand Down Expand Up @@ -59,12 +60,12 @@ def do_file(f, mode):
if actionname[-7:] == "Actions":
if tokens.next() != "{":
try:
print classname
print(classname)
except:
pass

try:
print actionname
print(actionname)
except:
pass

Expand Down Expand Up @@ -92,31 +93,31 @@ def do_file(f, mode):

if mode == "include":
# hack hack hack!!
print "#include <lib/" + '/'.join(f.split('/')[-2:]) + ">"
print("#include <lib/" + '/'.join(f.split('/')[-2:]) + ">")
else:
print "\t// " + f
print("\t// " + f)

firsthit = 0

if mode == "parse":
print "{\"" + actionname + "\", \"" + t + "\", " + "::".join((classname, t)) + "},"
print("{\"" + actionname + "\", \"" + t + "\", " + "::".join((classname, t)) + "},")

counter += 1


mode = sys.argv[1]

if mode == "parse":
print """
print("""
/* generated by parseactions.py - do not modify! */
struct eActionList
{
const char *m_context, *m_action;
int m_id;
} actions[]={"""
} actions[]={""")

for x in sys.argv[2:]:
do_file(x, mode)

if mode == "parse":
print "};"
print("};")
5 changes: 3 additions & 2 deletions lib/python/Components/AVSwitch.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
from config import config, ConfigSlider, ConfigSelection, ConfigYesNo, ConfigEnableDisable, ConfigSubsection, ConfigBoolean, ConfigSelectionNumber, ConfigNothing, NoSave
from enigma import eAVSwitch, eDVBVolumecontrol, getDesktop
from SystemInfo import SystemInfo
Expand Down Expand Up @@ -205,11 +206,11 @@ def setAlpha(config):
def setScaler_sharpness(config):
myval = int(config.value)
try:
print "--> setting scaler_sharpness to: %0.8X" % myval
print("--> setting scaler_sharpness to: %0.8X" % myval)
open("/proc/stb/vmpeg/0/pep_scaler_sharpness", "w").write("%0.8X" % myval)
open("/proc/stb/vmpeg/0/pep_apply", "w").write("1")
except IOError:
print "couldn't write pep_scaler_sharpness"
print("couldn't write pep_scaler_sharpness")

config.av.scaler_sharpness = ConfigSlider(default=13, limits=(0, 26))
config.av.scaler_sharpness.addNotifier(setScaler_sharpness)
Expand Down
9 changes: 5 additions & 4 deletions lib/python/Components/ActionMap.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
from enigma import eActionMap

from Tools.KeyBindings import queryKeyBinding
Expand All @@ -19,7 +20,7 @@ def __init__(self, contexts=None, actions=None, prio=0):
unknown.remove(action)
break
if unknown:
print "[ActionMap] Keymap(s) '%s' -> Undefined action(s) '%s'." % (", ".join(contexts), ", ".join(unknown))
print("[ActionMap] Keymap(s) '%s' -> Undefined action(s) '%s'." % (", ".join(contexts), ", ".join(unknown)))

def setEnabled(self, enabled):
self.enabled = enabled
Expand Down Expand Up @@ -53,13 +54,13 @@ def execEnd(self):

def action(self, context, action):
if action in self.actions:
print "[ActionMap] Keymap '%s' -> Action = '%s'." % (context, action)
print("[ActionMap] Keymap '%s' -> Action = '%s'." % (context, action))
res = self.actions[action]()
if res is not None:
return res
return 1
else:
print "[ActionMap] Keymap '%s' -> Unknown action '%s'! (Typo in keymap?)" % (context, action)
print("[ActionMap] Keymap '%s' -> Unknown action '%s'! (Typo in keymap?)" % (context, action))
return 0

def destroy(self):
Expand Down Expand Up @@ -94,7 +95,7 @@ def __init__(self, parent, contexts, actions=None, prio=0, description=None):
def exists(record):
for context in parent.helpList:
if record in context[2]:
print "[HelpActionMap] removed duplicity: %s %s" % (context[1], record)
print("[HelpActionMap] removed duplicity: %s %s" % (context[1], record))
return True
return False

Expand Down
11 changes: 6 additions & 5 deletions lib/python/Components/Console.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import enigma
import ctypes
import os
Expand Down Expand Up @@ -36,7 +37,7 @@ def dataAvailCB(self, data):
self.appResults.append(data)

def finishedCB(self, retval):
print "[Console] finished:", self.name
print("[Console] finished:", self.name)
del self.containers[self.name]
del self.container.dataAvail[:]
del self.container.appClosed[:]
Expand All @@ -54,7 +55,7 @@ def __init__(self):
self.appContainers = {}

def ePopen(self, cmd, callback=None, extra_args=[]):
print "[Console] command:", cmd
print("[Console] command:", cmd)
return ConsoleItem(self.appContainers, cmd, callback, extra_args)

def eBatch(self, cmds, callback, extra_args=[], debug=False):
Expand All @@ -65,7 +66,7 @@ def eBatch(self, cmds, callback, extra_args=[], debug=False):
def eBatchCB(self, data, retval, _extra_args):
(cmds, callback, extra_args) = _extra_args
if self.debug:
print '[eBatch] retval=%s, cmds left=%d, data:\n%s' % (retval, len(cmds), data)
print('[eBatch] retval=%s, cmds left=%d, data:\n%s' % (retval, len(cmds), data))
if cmds:
cmd = cmds.pop(0)
self.ePopen(cmd, self.eBatchCB, [cmds, callback, extra_args])
Expand All @@ -74,10 +75,10 @@ def eBatchCB(self, data, retval, _extra_args):

def kill(self, name):
if name in self.appContainers:
print "[Console] killing: ", name
print("[Console] killing: ", name)
self.appContainers[name].container.kill()

def killAll(self):
for name, item in self.appContainers.items():
print "[Console] killing: ", name
print("[Console] killing: ", name)
item.container.kill()
5 changes: 3 additions & 2 deletions lib/python/Components/Converter/ConfigEntryTest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
from Converter import Converter
from Components.Element import cached

Expand Down Expand Up @@ -36,12 +37,12 @@ def __init__(self, argstr):
else:
self.argerror = True
if self.argerror:
print "ConfigEntryTest Converter got incorrect arguments", args, "!!!\narg[0] must start with 'config.',\narg[1] is the compare string,\narg[2],arg[3] are optional arguments and must be 'Invert' or 'CheckSourceBoolean'"
print("ConfigEntryTest Converter got incorrect arguments", args, "!!!\narg[0] must start with 'config.',\narg[1] is the compare string,\narg[2],arg[3] are optional arguments and must be 'Invert' or 'CheckSourceBoolean'")

@cached
def getBoolean(self):
if self.argerror:
print "ConfigEntryTest got invalid arguments", self.converter_arguments, "force True!!"
print("ConfigEntryTest got invalid arguments", self.converter_arguments, "force True!!")
return True
if self.checkSourceBoolean and not self.source.boolean:
return False
Expand Down
3 changes: 2 additions & 1 deletion lib/python/Components/Converter/RdsInfo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
from enigma import iRdsDecoder, iPlayableService
from Components.Converter.Converter import Converter
from Components.Element import cached
Expand Down Expand Up @@ -26,7 +27,7 @@ def getText(self):
elif self.type == self.RTP_TEXT_CHANGED:
text = decoder.getText(iRdsDecoder.RtpText)
else:
print "unknown RdsInfo Converter type", self.type
print("unknown RdsInfo Converter type", self.type)
return text

text = property(getText)
Expand Down
3 changes: 2 additions & 1 deletion lib/python/Components/Converter/RotorPosition.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
from Converter import Converter
from Components.Element import cached
from Components.config import config
Expand Down Expand Up @@ -41,7 +42,7 @@ def frontendRotorPosition(slot):
elif value == "all":
all_text = ""
for x in nimmanager.nim_slots:
print x.slot
print(x.slot)
nim_text = nimmanager.rotorLastPositionForNim(x.slot, number=False)
if nim_text != _("rotor is not used"):
if nim_text == _("undefined"):
Expand Down
3 changes: 2 additions & 1 deletion lib/python/Components/Converter/StaticMultiList.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
from enigma import eListboxPythonMultiContent
from Components.Converter.StringList import StringList

Expand All @@ -22,5 +23,5 @@ def changed(self, what):
if self.source:
self.content.setList(self.source.list)

print "downstream_elements:", self.downstream_elements
print("downstream_elements:", self.downstream_elements)
self.downstream_elements.changed(what)
7 changes: 4 additions & 3 deletions lib/python/Components/Converter/StringList.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
from Converter import Converter
from enigma import eListboxPythonStringContent
from Components.Element import cached
Expand All @@ -23,11 +24,11 @@ def selectionChanged(self, index):

def setIndex(self, index):
# update all non-master targets
print "changed selection in listbox!"
print("changed selection in listbox!")
for x in self.downstream_elements:
print "downstream element", x
print("downstream element", x)
if x is not self.master:
print "is not master, so update to index", index
print("is not master, so update to index", index)
x.index = index

def getIndex(self, index):
Expand Down
5 changes: 3 additions & 2 deletions lib/python/Components/EpgList.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
from GUIComponent import GUIComponent

from enigma import eEPGCache, eListbox, eListboxPythonMultiContent, gFont, RT_HALIGN_LEFT, RT_HALIGN_RIGHT, RT_HALIGN_CENTER, RT_VALIGN_CENTER
Expand Down Expand Up @@ -400,11 +401,11 @@ def fillSimilarList(self, refstr, event_id):
l.sort(key=lambda x: x[2])
self.l.setList(l)
self.selectionChanged()
print time() - t
print(time() - t)

def applySkin(self, desktop, parent):
def warningWrongSkinParameter(string):
print "[EPGList] wrong '%s' skin parameters" % string
print("[EPGList] wrong '%s' skin parameters" % string)

def setEventItemFont(value):
self.eventItemFont = parseFont(value, ((1, 1), (1, 1)))
Expand Down
5 changes: 3 additions & 2 deletions lib/python/Components/FanControl.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import os

from Components.config import config, ConfigSubList, ConfigSubsection, ConfigSlider
Expand All @@ -22,14 +23,14 @@ def setVoltage_PWM(self):
cfg = self.getConfig(fanid)
self.setVoltage(fanid, cfg.vlt.value)
self.setPWM(fanid, cfg.pwm.value)
print "[FanControl]: setting fan values: fanid = %d, voltage = %d, pwm = %d" % (fanid, cfg.vlt.value, cfg.pwm.value)
print("[FanControl]: setting fan values: fanid = %d, voltage = %d, pwm = %d" % (fanid, cfg.vlt.value, cfg.pwm.value))

def setVoltage_PWM_Standby(self):
for fanid in range(self.getFanCount()):
cfg = self.getConfig(fanid)
self.setVoltage(fanid, cfg.vlt_standby.value)
self.setPWM(fanid, cfg.pwm_standby.value)
print "[FanControl]: setting fan values (standby mode): fanid = %d, voltage = %d, pwm = %d" % (fanid, cfg.vlt_standby.value, cfg.pwm_standby.value)
print("[FanControl]: setting fan values (standby mode): fanid = %d, voltage = %d, pwm = %d" % (fanid, cfg.vlt_standby.value, cfg.pwm_standby.value))

def getRecordEvent(self, recservice, event):
recordings = len(NavigationInstance.instance.getRecordings())
Expand Down
3 changes: 2 additions & 1 deletion lib/python/Components/FileList.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import print_function
import os
import re
from MenuList import MenuList
Expand Down Expand Up @@ -362,7 +363,7 @@ def changeSelectionState(self):
try:
self.selectedFiles.remove(os.path.normpath(realPathname))
except (IOError, OSError) as err:
print "[FileList] Error %d: Can't remove '%s'! (%s)" % (err.errno, realPathname, err.strerror)
print("[FileList] Error %d: Can't remove '%s'! (%s)" % (err.errno, realPathname, err.strerror))
else:
SelectState = True
if (realPathname not in self.selectedFiles) and (os.path.normpath(realPathname) not in self.selectedFiles):
Expand Down
Loading

0 comments on commit 5161301

Please sign in to comment.