Skip to content

Commit

Permalink
Merge branch 'Developer' into Python3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Ev0-BH committed Oct 8, 2023
2 parents ecb254b + 039f4f9 commit 8d55304
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 160 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/enigma2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
echo "checking locale format..."
find . -type f -name "*.po" -exec msgfmt {} -o {}.mo \;
echo "checking PEP8 validation..."
flake8 --builtins="_,ngettext,pgettext" --ignore=W191,W503,W504,E128,E501,E722 . --exit-zero
flake8 --builtins="_,ngettext,pgettext" --ignore=W191,W503,W504,E123,E126,E128,E501,E722 . --exit-zero
echo "check format PEP8 completed!"
# PEP8 :- IGNORE CODES
Expand Down
4 changes: 2 additions & 2 deletions lib/python/Components/ChoiceList.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ def ChoiceEntryComponent(key=None, text=None):
else:
res.append((eListboxPythonMultiContent.TYPE_TEXT, x, y, w, h, 0, RT_HALIGN_LEFT, "-" * 200))
else:
x, y, w, h = parameters.get("ChoicelistName", applySkinFactor(45, 2, 800, 25))
res.append((eListboxPythonMultiContent.TYPE_TEXT, x, y, w, h, 0, RT_HALIGN_LEFT, text[0]))
if key:
x, y, w, h = parameters.get("ChoicelistName", applySkinFactor(45, 2, 800, 25))
res.append((eListboxPythonMultiContent.TYPE_TEXT, x, y, w, h, 0, RT_HALIGN_LEFT, text[0]))
# separate the sizes definition for keybutton is=cons and the rest so there to be possibility to use different size images for different type icons
iconKeyConfigName = "ChoicelistIcon"
if key == "expandable":
Expand Down
11 changes: 8 additions & 3 deletions lib/python/Components/MenuList.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class MenuList(GUIComponent):
def __init__(self, list, enableWrapAround=True, content=eListboxPythonStringContent):
GUIComponent.__init__(self)
self.l = content()
self.setList(list)
self.list = list
self.onSelectionChanged = []
self.enableWrapAround = enableWrapAround

Expand Down Expand Up @@ -36,8 +36,13 @@ def getSelectedIndex(self):
return self.l.getCurrentSelectionIndex()

def setList(self, list):
self.list = list
self.l.setList(self.list)
self.__list = list
self.l.setList(self.__list)

def getList(self):
return self.__list

list = property(getList, setList)

def moveToIndex(self, idx):
if self.instance is not None:
Expand Down
12 changes: 6 additions & 6 deletions lib/python/Screens/CCcamInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,12 +735,12 @@ def showCCcamProviders(self, html):
infoList = []
lines = html.split("\n")

for l in lines:
if l.__contains__('|'):
for x in lines:
if x.__contains__('|'):
if firstLine:
firstLine = False
else:
list = l.split('|')
list = x.split('|')
if len(list) > 5:
caid = list[1].replace(" ", "")
if caid != "":
Expand Down Expand Up @@ -1043,10 +1043,10 @@ def readSharesCallback(self, html):
totalcards += 1
# maxdown = list[6]
# while maxdown.startswith(" "):
# maxdown = maxdown[1:]
# down = maxdown
# maxdown = maxdown[1:]
# down = maxdown
# if int(down)>0:
# resharecards +=1
# resharecards +=1

self.instance.setTitle("%s (%s %d) %s %s" % (_("Share View"), _("Total cards:"), totalcards, _("Hops:"), ulevel))
self["title"].setText("%s (%s %d) %s %s" % (_("Share View"), _("Total cards:"), totalcards, _("Hops:"), ulevel))
Expand Down
3 changes: 1 addition & 2 deletions lib/python/Screens/ChoiceBox.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@


class ChoiceBox(Screen):
def __init__(self, session, title="", list=None, keys=None, selection=0, skin_name=None, text="", reorderConfig="",
windowTitle=None, var="", callbackList=None):
def __init__(self, session, title="", list=None, keys=None, selection=0, skin_name=None, text="", reorderConfig="", windowTitle=None, var="", callbackList=None):
# list is in the format (<display text>, [<parameters to pass to close callback>,])
# callbackList is in the format (<display text>, <callback func>, [<parameters>,])
self.isCallbackList = bool(callbackList)
Expand Down
8 changes: 4 additions & 4 deletions lib/python/Screens/InputDeviceSetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ def __init__(self, session):

self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
{
"cancel": (self.close, _("Exit input device selection.")),
"ok": (self.okbuttonClick, _("Select input device.")),
"cancel": (self.close, _("Exit input device selection.")),
"ok": (self.okbuttonClick, _("Select input device.")),
}, -2)

self["ColorActions"] = HelpableActionMap(self, "ColorActions",
{
"red": (self.close, _("Exit input device selection.")),
"green": (self.okbuttonClick, _("Select input device.")),
"red": (self.close, _("Exit input device selection.")),
"green": (self.okbuttonClick, _("Select input device.")),
}, -2)

self.currentIndex = 0
Expand Down
2 changes: 1 addition & 1 deletion lib/python/Screens/LogManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def __init__(self, session, logpath=None):
"left": self.goLeft,
"right": self.goRight,
"0": self.doRefresh,
}, -1)
}, -1)
self.onLayoutFinish.append(self.mainlist)

def exit(self):
Expand Down
67 changes: 31 additions & 36 deletions lib/python/Screens/MovieSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from Screens.HelpMenu import HelpableScreen
from Screens.InputBox import PinInput
import Screens.InfoBar
from Screens.ParentalControlSetup import ProtectedScreen
from Tools import NumericalTextInput
from Tools.Directories import resolveFilename, SCOPE_HDD
from Tools.BoundFunction import boundFunction
Expand Down Expand Up @@ -165,7 +166,7 @@ def canDelete(item):


def createMoveList(serviceref, dest):
#normpath is to remove the trailing '/' from directories
# normpath is to remove the trailing '/' from directories
src = isinstance(serviceref, str) and "%s.%s" % (serviceref, "ts" if os.path.exists("%s.ts" % serviceref) else "stream") or os.path.normpath(serviceref.getPath())
srcPath, srcName = os.path.split(src)
if os.path.normpath(srcPath) == dest:
Expand All @@ -191,7 +192,6 @@ def createMoveList(serviceref, dest):
def moveServiceFiles(serviceref, dest, name=None, allowCopy=True):
moveList = createMoveList(serviceref, dest)
# Try to "atomically" move these files
movedList = []
try:
# print("[MovieSelection] Moving in background...")
# start with the smaller files, do the big one later.
Expand All @@ -209,7 +209,6 @@ def copyServiceFiles(serviceref, dest, name=None):
# current should be 'ref' type, dest a simple path string
moveList = createMoveList(serviceref, dest)
# Try to "atomically" move these files
movedList = []
try:
# print("[MovieSelection] Copying in background...")
# start with the smaller files, do the big one later.
Expand Down Expand Up @@ -386,9 +385,6 @@ def selectionChanged(self):
self["selected"].text = self.parent["config"].getCurrent()[0][0]


from Screens.ParentalControlSetup import ProtectedScreen


class MovieContextMenu(Screen, ProtectedScreen):
# Contract: On OK returns a callable object (e.g. delete)
def __init__(self, session, csel, currentSelection):
Expand Down Expand Up @@ -715,10 +711,10 @@ def __init__(self, session, selectedmovie=None, timeshiftEnabled=False):
tPreview = _("Preview")
tFwd = _("skip forward") + " (" + tPreview + ")"
tBack = _("skip backward") + " (" + tPreview + ")"
sfwd = lambda: self.seekRelative(1, config.seek.selfdefined_46.value * 90000)
ssfwd = lambda: self.seekRelative(1, config.seek.selfdefined_79.value * 90000)
sback = lambda: self.seekRelative(-1, config.seek.selfdefined_46.value * 90000)
ssback = lambda: self.seekRelative(-1, config.seek.selfdefined_79.value * 90000)
sfwd = lambda: self.seekRelative(1, config.seek.selfdefined_46.value * 90000) # noqa: E731
ssfwd = lambda: self.seekRelative(1, config.seek.selfdefined_79.value * 90000) # noqa: E731
sback = lambda: self.seekRelative(-1, config.seek.selfdefined_46.value * 90000) # noqa: E731
ssback = lambda: self.seekRelative(-1, config.seek.selfdefined_79.value * 90000) # noqa: E731
self["SeekActions"] = HelpableActionMap(self, "MovielistSeekActions",
{
"playpauseService": (self.preview, _("Preview")),
Expand All @@ -733,10 +729,10 @@ def __init__(self, session, selectedmovie=None, timeshiftEnabled=False):
self.onClose.append(self.__onClose)
NavigationInstance.instance.RecordTimer.on_state_change.append(self.list.updateRecordings)
self.__event_tracker = ServiceEventTracker(screen=self, eventmap={
#iPlayableService.evSeekableStatusChanged: self.__seekableStatusChanged,
# iPlayableService.evSeekableStatusChanged: self.__seekableStatusChanged,
iPlayableService.evStart: self.__serviceStarted,
iPlayableService.evEOF: self.__evEOF,
#iPlayableService.evSOF: self.__evSOF,
# iPlayableService.evSOF: self.__evSOF,
})
self.onExecBegin.append(self.asciiOn)
config.misc.standbyCounter.addNotifier(self.standbyCountChanged, initial_call=False)
Expand Down Expand Up @@ -1386,11 +1382,11 @@ def __playCurrentItem(self):
path = current.getPath()
if current.flags & eServiceReference.mustDescent:
if BlurayPlayer is not None and os.path.isdir(os.path.join(path, 'BDMV/STREAM/')):
#force a BLU-RAY extention
# force a BLU-RAY extention
Screens.InfoBar.InfoBar.instance.checkTimeshiftRunning(boundFunction(self.itemSelectedCheckTimeshiftCallback, 'bluray', path))
return
if os.path.isdir(os.path.join(path, 'VIDEO_TS/')) or os.path.exists(os.path.join(path, 'VIDEO_TS.IFO')):
#force a DVD extention
# force a DVD extention
Screens.InfoBar.InfoBar.instance.checkTimeshiftRunning(boundFunction(self.itemSelectedCheckTimeshiftCallback, '.img', path))
return
self.gotFilename(path)
Expand Down Expand Up @@ -1488,14 +1484,13 @@ def loadLocalSettings(self):
updates = pickle.load(file)
file.close()
self.applyConfigSettings(updates)
except IOError as e:
except IOError: # ignore fail to open errors
updates = {
"moviesort": config.movielist.moviesort.default,
"description": config.movielist.description.default,
"movieoff": config.usage.on_movie_eof.default
}
self.applyConfigSettings(updates)
pass # ignore fail to open errors
except Exception as e:
print("[MovieSelection] Failed to load settings from %s: %s" % (path, e))
else:
Expand All @@ -1506,10 +1501,10 @@ def loadLocalSettings(self):
}
self.applyConfigSettings(updates)

# Remember this starting sort method for this dir.
# selectSortby() needs this to highlight the current sort and
# do_sort() needs it to know whence to move on.
#
# Remember this starting sort method for this dir.
# selectSortby() needs this to highlight the current sort and
# do_sort() needs it to know whence to move on.
#
self["list"].current_sort = self.settings["moviesort"]

def applyConfigSettings(self, updates):
Expand All @@ -1533,22 +1528,22 @@ def sortBy(self, newType):
print("[MovieSelection] SORTBY:", newType)
if newType < MovieList.TRASHSORT_SHOWRECORD:
self.settings["moviesort"] = newType
# If we are using per-directory sort methods then set it now...
#
# If we are using per-directory sort methods then set it now...
#
if config.movielist.settings_per_directory.value:
self.saveLocalSettings()
else:
# ..otherwise, if we are setting permanent sort methods, save it,
# while, for temporary sort methods, indicate to MovieList.py to
# use a temporary sort override.
#
# ..otherwise, if we are setting permanent sort methods, save it,
# while, for temporary sort methods, indicate to MovieList.py to
# use a temporary sort override.
#
if config.movielist.perm_sort_changes.value:
config.movielist.moviesort.setValue(newType)
config.movielist.moviesort.save()
else:
self["list"].temp_sort = newType
self.setSortType(newType)
# Unset specific trash-sorting if other sort chosen while in Trash
# Unset specific trash-sorting if other sort chosen while in Trash
if MovieList.InTrashFolder:
config.usage.trashsort_deltime.value = "no"
else:
Expand Down Expand Up @@ -1597,7 +1592,7 @@ def configure(self):
def configureDone(self, result):
if result:
self.applyConfigSettings({
"moviesort": config.movielist.moviesort.value,
"moviesort": config.movielist.moviesort.value,
"description": config.movielist.description.value,
"movieoff": config.usage.on_movie_eof.value})
self.saveLocalSettings()
Expand Down Expand Up @@ -1762,7 +1757,7 @@ def servicePinEntered(res, selItem, result):
parentalControl.setSessionPinCached()
parentalControl.hideBlacklist()
self.gotFilename(res, selItem)
elif result == False:
elif result is False:
self.session.open(MessageBox, _("The pin code you entered is wrong."), MessageBox.TYPE_INFO, timeout=3)
if not res:
return
Expand Down Expand Up @@ -1829,7 +1824,7 @@ def showAll(self):
def showTagsN(self, tagele):
if not self.tags:
self.showTagWarning()
elif not tagele or (self.selected_tags and tagele.value in self.selected_tags) or not tagele.value in self.tags:
elif not tagele or (self.selected_tags and tagele.value in self.selected_tags) or tagele.value not in self.tags:
self.showTagsMenu(tagele)
else:
self.selected_tags_ele = tagele
Expand Down Expand Up @@ -2083,7 +2078,7 @@ def renameCallback(self, renameList, newname):
else:
metafile = open(meta, "r+")
sid = metafile.readline()
oldtitle = metafile.readline()
oldtitle = metafile.readline() #noqa: F841 # local variable 'oldtitle' is assigned to but never used. Must be to skip a line.
rest = metafile.read()
metafile.seek(0)
metafile.write("%s%s\n%s" % (sid, newname, rest))
Expand Down Expand Up @@ -2162,7 +2157,7 @@ def do_move(self):
# show a more limited list of destinations, no point in showing mountpoints.
title = _("Select destination for:") + " " + name
bookmarks = buildMovieLocationList(includeOther=True, path=path, includeSubdirs=True, includeParentDir=True)
callback = lambda choice: self.gotMoveMovieDest(moveList, choice)
callback = lambda choice: self.gotMoveMovieDest(moveList, choice) # noqa: E731
self.session.openWithCallback(lambda choice: self.gotMovieLocation(title, callback, choice), ChoiceBox, title=title, list=bookmarks)

def gotMoveMovieDest(self, moveList, choice):
Expand Down Expand Up @@ -2309,7 +2304,7 @@ def __onTimerChoiceDelete(self, delList, recList, delInfo):

def __showDeleteConfirmation(self, delList, delInfo):
dirCount, fileCount, subItemCount, inTrash = delInfo
callback = lambda confirmed: self.__permanentDeleteListConfirmed(delList, confirmed)
callback = lambda confirmed: self.__permanentDeleteListConfirmed(delList, confirmed) # noqa: E731
itemCount = dirCount + fileCount
singleName = None
if itemCount == 1:
Expand All @@ -2325,7 +2320,7 @@ def __showDeleteConfirmation(self, delList, delInfo):
are_you_sure = _("Do you really want to move '%s' to the trash can?") % singleName
else:
are_you_sure = _("Do you really want to move these %d items to the trash can?") % itemCount
callback = lambda confirmed: self.__deleteListConfirmed(delList, confirmed)
callback = lambda confirmed: self.__deleteListConfirmed(delList, confirmed) # noqa: E731
else:
if itemCount == 1:
are_you_sure = _("Do you really want to permanently delete '%s'?") % singleName
Expand Down Expand Up @@ -2503,7 +2498,7 @@ def do_sort(self):
index = 0
else:
index += 1
#descriptions in native languages too long...
# descriptions in native languages too long...
sorttext = l_moviesort[index][2]
if config.movielist.btn_red.value == "sort":
self['key_red'].setText(sorttext)
Expand All @@ -2521,7 +2516,7 @@ def do_sort(self):

def installedMovieManagerPlugin(self):
try:
from Plugins.Extensions.MovieManager.ui import MovieManager
from Plugins.Extensions.MovieManager.ui import MovieManager # noqa: F401
return True
except Exception as e:
print("[MovieSelection] MovieManager is not installed...", e)
Expand Down

0 comments on commit 8d55304

Please sign in to comment.