Skip to content

Commit

Permalink
Fix some python warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jbleyel committed Aug 25, 2024
1 parent 672aa08 commit 4a969a0
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 81 deletions.
10 changes: 5 additions & 5 deletions lib/python/Components/ServiceList.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def parseTemplateModes(template):

newitems = []
if self.debug:
print(f"[ServiceListTemplateParser] DEBUG newitems")
print("[ServiceListTemplateParser] DEBUG newitems")
print(items)
for item in items:
itemsAttibutes = {}
Expand Down Expand Up @@ -970,8 +970,8 @@ def _calcTextWidth(text, font, size):

addtimedisplayWidth = 0
addtimedisplay = ""
textTpl = ""
maxTimeValue = 9999
# textTpl = ""
# maxTimeValue = 9999

match mode:
case 1: # Title
Expand Down Expand Up @@ -1066,7 +1066,7 @@ def buildOptionEntryServicePixmap(self, service):

def buildOptionEntryServiceResolutionPixmap(self, service): # TODO Resolution type icon
pixmap = None
resolutionType = service.getUnsignedData(2)
# resolutionType = service.getUnsignedData(2)
return pixmap

def buildOptioncheckHasRecordings(self, service, isPlayable):
Expand Down Expand Up @@ -1403,7 +1403,7 @@ def getColor(defaults, attributes, serviceAvail, marked):
borderColorSelected = item.get("borderColorSelected", defaults.get("borderColorSelected")) if borderWidth else None
res.append((MultiContentEntryProgress(pos=pos, size=size, percent=percent, borderWidth=borderWidth, foreColor=foregroundColor, foreColorSelected=foregroundColorSelected, backColor=backgroundColor, backColorSelected=backgroundColor, borderColor=borderColor, borderColorSelected=borderColorSelected, startColor=gradientStart, midColor=gradientMid, endColor=gradientEnd, startColorSelected=gradientStartSelected, midColorSelected=gradientMidSelected, endColorSelected=gradientEndSelected, cornerRadius=cornerRadius, cornerEdges=cornerEdges)))

except Exception as error:
except Exception:
import traceback
traceback.print_exception()

Expand Down
30 changes: 15 additions & 15 deletions lib/python/Components/TimerSanityCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def checkTimerlist(self, ext_timer=1):
newTimerTunerType = None
cnt = 0
idx = 0
is_ci_use = 0
# is_ci_use = 0
is_ci_timer_conflict = 0
overlaplist = []
ci_timer = False
Expand All @@ -172,7 +172,7 @@ def checkTimerlist(self, ext_timer=1):
cnt += event[1]
timer = self.newtimer if event[2] == -1 else self.timerlist[event[2]] # New timer.
if event[1] == self.bflag:
tunerType = []
tunerTypes = []
if timer.service_ref.ref and timer.service_ref.ref.flags & eServiceReference.isGroup:
fakeRecService = NavigationInstance.instance.recordService(getBestPlayableServiceReference(timer.service_ref.ref, eServiceReference(), True), True)
else:
Expand All @@ -185,17 +185,17 @@ def checkTimerlist(self, ext_timer=1):
if not fakeRecResult: # Tune okay.
# feinfo = fakeRecService.frontendInfo()
# if feinfo:
# tunerType.append(feinfo.getFrontendData().get("tuner_type"))
# tunerTypes.append(feinfo.getFrontendData().get("tuner_type"))
if hasattr(fakeRecService, "frontendInfo") and hasattr(fakeRecService.frontendInfo(), "getFrontendData"):
feinfo = fakeRecService.frontendInfo().getFrontendData()
if "tuner_number" in feinfo:
nim = nimmanager.nim_slots[int(feinfo.get("tuner_number"))]
if nim.isCompatible("DVB-T"):
tunerType.append("DVB-T")
tunerTypes.append("DVB-T")
elif nim.isCompatible("DVB-C"):
tunerType.append("DVB-C")
if not tunerType:
tunerType.append(feinfo.get("tuner_type"))
tunerTypes.append("DVB-C")
if not tunerTypes:
tunerTypes.append(feinfo.get("tuner_type"))
else: # Tune failed. We must go another way to get service type (DVB-S, DVB-T, DVB-C).
def getServiceType(ref): # Helper function to get a service type of a service reference.
serviceInfo = serviceHandler.info(ref)
Expand All @@ -207,19 +207,19 @@ def getServiceType(ref): # Helper function to get a service type of a service r
serviceList = serviceHandler.list(ref) # Get all alternative services.
if serviceList:
for ref in serviceList.getContent("R"): # Iterate over all group service references.
type = getServiceType(ref)
if type not in tunerType: # Just add single time.
tunerType.append(type)
tunerType = getServiceType(ref)
if tunerType not in tunerTypes: # Just add single time.
tunerTypes.append(tunerType)
else:
tunerType.append(getServiceType(ref))
tunerTypes.append(getServiceType(ref))
if event[2] == -1: # New timer.
newTimerTunerType = tunerType
overlaplist.append((fakeRecResult, timer, tunerType))
newTimerTunerType = tunerTypes
overlaplist.append((fakeRecResult, timer, tunerTypes))
fakeRecList.append((timer, fakeRecService))
if fakeRecResult:
if ConflictTimer is None: # Just take care of the first conflict.
ConflictTimer = timer
ConflictTunerType = tunerType
ConflictTunerType = tunerTypes
elif event[1] == self.eflag:
for fakeRec in fakeRecList:
if timer == fakeRec[0] and fakeRec[1]:
Expand Down Expand Up @@ -247,7 +247,7 @@ def getServiceType(ref): # Helper function to get a service type of a service r
if is_ci_timer_conflict == 1:
if ConflictTimer is None:
ConflictTimer = timer
ConflictTunerType = tunerType
ConflictTunerType = tunerTypes
self.nrep_eventlist[idx] = (event[0], event[1], event[2], cnt, overlaplist[:]) # Insert a duplicate into current overlap list.
idx += 1
if ConflictTimer is None: # No conflict found. :)
Expand Down
85 changes: 42 additions & 43 deletions lib/python/Plugins/Extensions/AtileHD/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
#it without source code (this version and your modifications).
#This means you also have to distribute
#source code of your modifications.

from os import listdir, readlink, remove, rename, symlink, chdir, makedirs, mkdir
from os.path import basename, exists, isdir, islink, realpath
from shutil import rmtree
from enigma import eTimer
from Components.ActionMap import ActionMap
from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection, ConfigYesNo, NoSave, ConfigNothing, ConfigNumber
Expand All @@ -22,11 +24,9 @@
from Screens.MessageBox import MessageBox
from Screens.Screen import Screen
from Screens.Standby import TryQuitMainloop
from Tools.Directories import *
from Tools.Directories import resolveFilename, SCOPE_SKINS
from Tools.LoadPixmap import LoadPixmap
from Tools.WeatherID import get_woeid_from_yahoo
from os import listdir, remove, rename, path, symlink, chdir, makedirs, mkdir
import shutil

cur_skin = config.skin.primary_skin.value.replace('/skin.xml', '')

Expand Down Expand Up @@ -82,10 +82,9 @@ class WeatherLocationChoiceList(Screen):

def __init__(self, session, location_list):
self.location_list = location_list
list = []
Screen.__init__(self, session)
self.title = _("Location list")
self["choicelist"] = MenuList(list)
self["choicelist"] = MenuList([])
self["key_red"] = Label(_("Cancel"))
self["key_green"] = Label(_("OK"))
self["myActionMap"] = ActionMap(["SetupActions", "ColorActions"],
Expand All @@ -98,11 +97,11 @@ def __init__(self, session, location_list):
self.createChoiceList()

def createChoiceList(self):
list = []
choiceList = []
print(self.location_list)
for x in self.location_list:
list.append((str(x[1]), str(x[0])))
self["choicelist"].l.setList(list)
choiceList.append((str(x[1]), str(x[0])))
self["choicelist"].l.setList(choiceList)

def keyOk(self):
returnValue = self["choicelist"].l.getCurrentSelection()[1]
Expand Down Expand Up @@ -175,7 +174,7 @@ def setWeather(self):
try:
from Plugins.Extensions.WeatherPlugin.setup import MSNWeatherPluginEntriesListConfigScreen
self.session.open(MSNWeatherPluginEntriesListConfigScreen)
except:
except ImportError:
self.session.open(MessageBox, _("'WeatherPlugin' is not installed!"), MessageBox.TYPE_INFO)

def getInitConfig(self):
Expand Down Expand Up @@ -261,12 +260,12 @@ def getSettings(self, default_file, user_file):
# possible setting
choices = []
files = listdir(self.skin_base_dir)
if path.exists(self.skin_base_dir + 'allScreens/%s/' % styp):
if exists(self.skin_base_dir + 'allScreens/%s/' % styp):
files += listdir(self.skin_base_dir + 'allScreens/%s/' % styp)
for f in sorted(files, key=str.lower):
if f.endswith('.xml') and f.startswith(search_str):
friendly_name = f.replace(search_str, "").replace(".xml", "").replace("_", " ")
if path.exists(self.skin_base_dir + 'allScreens/%s/%s' % (styp, f)):
if exists(self.skin_base_dir + 'allScreens/%s/%s' % (styp, f)):
choices.append((self.skin_base_dir + 'allScreens/%s/%s' % (styp, f), friendly_name))
else:
choices.append((self.skin_base_dir + f, friendly_name))
Expand All @@ -275,14 +274,14 @@ def getSettings(self, default_file, user_file):
# current setting
myfile = self.skin_base_dir + user_file
current = ''
if not path.exists(myfile):
if path.exists(self.skin_base_dir + default_file):
if path.islink(myfile):
if not exists(myfile):
if exists(self.skin_base_dir + default_file):
if islink(myfile):
remove(myfile)
chdir(self.skin_base_dir)
symlink(default_file, user_file)
elif path.exists(self.skin_base_dir + 'allScreens/%s/%s' % (styp, default_file)):
if path.islink(myfile):
elif exists(self.skin_base_dir + 'allScreens/%s/%s' % (styp, default_file)):
if islink(myfile):
remove(myfile)
chdir(self.skin_base_dir)
symlink(self.skin_base_dir + 'allScreens/%s/%s' % (styp, default_file), user_file)
Expand All @@ -291,8 +290,8 @@ def getSettings(self, default_file, user_file):
if current is None:
current = default
else:
filename = path.realpath(myfile)
friendly_name = path.basename(filename).replace(search_str, "").replace(".xml", "").replace("_", " ")
filename = realpath(myfile)
friendly_name = basename(filename).replace(search_str, "").replace(".xml", "").replace("_", " ")
current = (filename, friendly_name)

return current[0], choices
Expand Down Expand Up @@ -418,15 +417,15 @@ def cancelConfirm(self, result):

def getmyAtileState(self):
chdir(self.skin_base_dir)
if path.exists("mySkin"):
if exists("mySkin"):
return True
else:
return False

def setPicture(self, f):
pic = f.split('/')[-1].replace(".xml", ".png")
preview = self.skin_base_dir + "preview/preview_" + pic
if path.exists(preview):
if exists(preview):
self["Picture"].instance.setPixmapFromFile(preview)
self["Picture"].show()
else:
Expand Down Expand Up @@ -509,19 +508,19 @@ def keyGreen(self):
# ul
self.makeSettings(self.myAtileHD_ul, self.ul_file)

if not path.exists("mySkin_off"):
if not exists("mySkin_off"):
mkdir("mySkin_off")
print("makedir mySkin_off")
if self.myAtileHD_active.value:
if not path.exists("mySkin") and path.exists("mySkin_off"):
if not exists("mySkin") and exists("mySkin_off"):
symlink("mySkin_off", "mySkin")
else:
if path.exists("mySkin"):
if path.exists("mySkin_off"):
if path.islink("mySkin"):
if exists("mySkin"):
if exists("mySkin_off"):
if islink("mySkin"):
remove("mySkin")
else:
shutil.rmtree("mySkin")
rmtree("mySkin")
else:
rename("mySkin", "mySkin_off")
self.restartGUI()
Expand All @@ -534,7 +533,7 @@ def keyGreen(self):
self.close()

def makeSettings(self, config_entry, user_file):
if path.exists(user_file) or path.islink(user_file):
if exists(user_file) or islink(user_file):
remove(user_file)
if config_entry.value != 'default':
symlink(config_entry.value, user_file)
Expand Down Expand Up @@ -634,11 +633,11 @@ def __init__(self, session):
self.skinparts_dir = "skinparts"
self.file_dir = "mySkin_off"
my_path = resolveFilename(SCOPE_SKINS, "%s/icons/lock_on.png" % cur_skin)
if not path.exists(my_path):
if not exists(my_path):
my_path = resolveFilename(SCOPE_SKINS, "skin_default/icons/lock_on.png")
self.enabled_pic = LoadPixmap(cached=True, path=my_path)
my_path = resolveFilename(SCOPE_SKINS, "%s/icons/lock_off.png" % cur_skin)
if not path.exists(my_path):
if not exists(my_path):
my_path = resolveFilename(SCOPE_SKINS, "skin_default/icons/lock_off.png")
self.disabled_pic = LoadPixmap(cached=True, path=my_path)

Expand All @@ -660,34 +659,34 @@ def createMenuList(self):
chdir(self.skin_base_dir)
f_list = []
dir_path = self.skin_base_dir + self.screen_dir
if not path.exists(dir_path):
if not exists(dir_path):
makedirs(dir_path)
dir_skinparts_path = self.skin_base_dir + self.skinparts_dir
if not path.exists(dir_skinparts_path):
if not exists(dir_skinparts_path):
makedirs(dir_skinparts_path)
file_dir_path = self.skin_base_dir + self.file_dir
if not path.exists(file_dir_path):
if not exists(file_dir_path):
makedirs(file_dir_path)
dir_global_skinparts = resolveFilename(SCOPE_SKINS, "skinparts")
if path.exists(dir_global_skinparts):
if exists(dir_global_skinparts):
for pack in listdir(dir_global_skinparts):
if path.isdir(dir_global_skinparts + "/" + pack):
if isdir(dir_global_skinparts + "/" + pack):
for f in listdir(dir_global_skinparts + "/" + pack):
if path.exists(dir_global_skinparts + "/" + pack + "/" + f + "/" + f + "_Atile.xml"):
if not path.exists(dir_path + "/skin_" + f + ".xml"):
if exists(dir_global_skinparts + "/" + pack + "/" + f + "/" + f + "_Atile.xml"):
if not exists(dir_path + "/skin_" + f + ".xml"):
symlink(dir_global_skinparts + "/" + pack + "/" + f + "/" + f + "_Atile.xml", dir_path + "/skin_" + f + ".xml")
if not path.exists(dir_skinparts_path + "/" + f):
if not exists(dir_skinparts_path + "/" + f):
symlink(dir_global_skinparts + "/" + pack + "/" + f, dir_skinparts_path + "/" + f)
list_dir = sorted(listdir(dir_path), key=str.lower)
for f in list_dir:
if f.endswith('.xml') and f.startswith('skin_'):
if (not path.islink(dir_path + "/" + f)) or os.path.exists(os.readlink(dir_path + "/" + f)):
if (not islink(dir_path + "/" + f)) or exists(readlink(dir_path + "/" + f)):
friendly_name = f.replace("skin_", "")
friendly_name = friendly_name.replace(".xml", "")
friendly_name = friendly_name.replace("_", " ")
linked_file = file_dir_path + "/" + f
if path.exists(linked_file):
if path.islink(linked_file):
if exists(linked_file):
if islink(linked_file):
pic = self.enabled_pic
else:
remove(linked_file)
Expand All @@ -697,7 +696,7 @@ def createMenuList(self):
pic = self.disabled_pic
f_list.append((f, friendly_name, pic))
else:
if path.islink(dir_path + "/" + f):
if islink(dir_path + "/" + f):
remove(dir_path + "/" + f)
menu_list = []
for entry in f_list:
Expand All @@ -708,7 +707,7 @@ def createMenuList(self):
def setPicture(self, f):
pic = f.replace(".xml", ".png")
preview = self.skin_base_dir + "preview/preview_" + pic
if path.exists(preview):
if exists(preview):
self["Picture"].instance.setPixmapFromFile(preview)
self["Picture"].show()
else:
Expand Down
Loading

0 comments on commit 4a969a0

Please sign in to comment.