Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safe PEP8 #14

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/ExtensionHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,36 @@ def addExtension():
from Plugins.Extensions.InfoBarTunerState.plugin import IBTSSHOW, IBTSSETUP, show, setup
if plugins:
if config.infobartunerstate.extensions_menu_show.value:
for p in plugins.getPlugins( where = PluginDescriptor.WHERE_EXTENSIONSMENU ):
for p in plugins.getPlugins(where=PluginDescriptor.WHERE_EXTENSIONSMENU):
if p.name == IBTSSHOW:
# Plugin is already in menu
break
else:
# Plugin not in menu - add it
plugin = PluginDescriptor(name = IBTSSHOW, description = IBTSSHOW, where = PluginDescriptor.WHERE_EXTENSIONSMENU, needsRestart = False, fnc = show)
plugin = PluginDescriptor(name=IBTSSHOW, description=IBTSSHOW, where=PluginDescriptor.WHERE_EXTENSIONSMENU, needsRestart=False, fnc=show)
plugins.plugins[PluginDescriptor.WHERE_EXTENSIONSMENU].append(plugin)
if config.infobartunerstate.extensions_menu_setup.value:
for p in plugins.getPlugins( where = PluginDescriptor.WHERE_EXTENSIONSMENU ):
for p in plugins.getPlugins(where=PluginDescriptor.WHERE_EXTENSIONSMENU):
if p.name == IBTSSETUP:
# Plugin is already in menu
break
else:
# Plugin not in menu - add it
plugin = PluginDescriptor(name = IBTSSETUP, description = IBTSSETUP, where = PluginDescriptor.WHERE_EXTENSIONSMENU, needsRestart = False, fnc = setup)
plugin = PluginDescriptor(name=IBTSSETUP, description=IBTSSETUP, where=PluginDescriptor.WHERE_EXTENSIONSMENU, needsRestart=False, fnc=setup)
plugins.plugins[PluginDescriptor.WHERE_EXTENSIONSMENU].append(plugin)


def removeExtension():
# Remove from extension menu
from Components.PluginComponent import plugins
from Plugins.Extensions.InfoBarTunerState.plugin import IBTSSHOW, IBTSSETUP
if config.infobartunerstate.extensions_menu_show.value:
for p in plugins.getPlugins( where = PluginDescriptor.WHERE_EXTENSIONSMENU ):
for p in plugins.getPlugins(where=PluginDescriptor.WHERE_EXTENSIONSMENU):
if p.name == IBTSSHOW:
plugins.plugins[PluginDescriptor.WHERE_EXTENSIONSMENU].remove(p)
break
if config.infobartunerstate.extensions_menu_setup.value:
for p in plugins.getPlugins( where = PluginDescriptor.WHERE_EXTENSIONSMENU ):
for p in plugins.getPlugins(where=PluginDescriptor.WHERE_EXTENSIONSMENU):
if p.name == IBTSSETUP:
plugins.plugins[PluginDescriptor.WHERE_EXTENSIONSMENU].remove(p)
break
32 changes: 16 additions & 16 deletions src/Handler/Live.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from Plugins.Extensions.InfoBarTunerState.Logger import log

# Config options
config.infobartunerstate.plugin_live = ConfigSubsection()
config.infobartunerstate.plugin_live.enabled = ConfigYesNo(default = False)
config.infobartunerstate.plugin_live = ConfigSubsection()
config.infobartunerstate.plugin_live.enabled = ConfigYesNo(default=False)


class Live(PluginBase):
Expand All @@ -38,7 +38,7 @@ def getPixmapNum(self):
return 4

def getOptions(self):
return [(_("Show live tuner"), config.infobartunerstate.plugin_live.enabled),]
return [(_("Show live tuner"), config.infobartunerstate.plugin_live.enabled), ]

def appendEvent(self):
if config.infobartunerstate.plugin_live.enabled.value:
Expand All @@ -64,29 +64,29 @@ def onInit(self):
def onEvent(self, ev):
#log.debug( "IBTS Live onEvent ev", ev, str(self.tunerstate) )
if ev == iPlayableService.evUpdatedEventInfo or ev == iPlayableService.evUpdatedInfo:

if self.tunerstate:
tunerstate = self.tunerstate

from NavigationInstance import instance
if instance:

changed = False

eservicereference = instance.getCurrentlyPlayingServiceReference()
eservicereference_string = str(eservicereference)

# Avoid recalculations
if self.eservicereference_string != eservicereference_string:
tunerstate.number = None
tunerstate.channel = ""
tunerstate.reference = ""

tunerstate.tuner, tunerstate.tunertype, tunerstate.tunernumber = "", "", None
tunerstate.name, tunerstate.begin, tunerstate.end = "", 0, 0

self.eservicereference_string = eservicereference_string

if not tunerstate.number:
tunerstate.number = getNumber(eservicereference)
changed = True
Expand All @@ -97,22 +97,22 @@ def onEvent(self, ev):
tunerstate.reference = str(ServiceReference(eservicereference))
tunerstate.updatePicon()
changed = True

iplayableservice = instance.getCurrentService()

if not tunerstate.tuner or not tunerstate.tunertype or not tunerstate.tunernumber:
tunerstate.tuner, tunerstate.tunertype, tunerstate.tunernumber = getTunerByPlayableService(iplayableservice)
changed = True

if not tunerstate.name or not tunerstate.begin or not tunerstate.end:
tunerstate.name, tunerstate.begin, tunerstate.end = getEventData(iplayableservice)
changed = True

if changed:
from Plugins.Extensions.InfoBarTunerState.plugin import gInfoBarTunerState
if gInfoBarTunerState:
gInfoBarTunerState.updateMetrics()

from Plugins.Extensions.InfoBarTunerState.plugin import gInfoBarTunerState
if gInfoBarTunerState:
gInfoBarTunerState.onEvent()
58 changes: 29 additions & 29 deletions src/Handler/PiP.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from Plugins.Extensions.InfoBarTunerState.Logger import log

# Config options
config.infobartunerstate.plugin_pip = ConfigSubsection()
config.infobartunerstate.plugin_pip.enabled = ConfigYesNo(default = False)
config.infobartunerstate.plugin_pip = ConfigSubsection()
config.infobartunerstate.plugin_pip.enabled = ConfigYesNo(default=False)


class PiP(PluginBase):
Expand All @@ -38,7 +38,7 @@ def getPixmapNum(self):
return 7

def getOptions(self):
return [(_("Show PiP service(s)"), config.infobartunerstate.plugin_pip.enabled),]
return [(_("Show PiP service(s)"), config.infobartunerstate.plugin_pip.enabled), ]

def appendEvent(self):
pass
Expand All @@ -47,13 +47,13 @@ def removeEvent(self):
pass

def checkPiP(self):
log.debug( "IBTS PiP check" )
log.debug("IBTS PiP check")
from Screens.InfoBar import InfoBar
if InfoBar.instance and InfoBar.instance.session and hasattr(InfoBar.instance.session, "pip"):
if hasattr(InfoBar.instance.session.pip, "currentService") and InfoBar.instance.session.pip.currentService is not None:
if hasattr(InfoBar.instance.session.pip, "currentService") and InfoBar.instance.session.pip.currentService is not None:
from Plugins.Extensions.InfoBarTunerState.plugin import gInfoBarTunerState
if gInfoBarTunerState:
log.debug( "IBTS PiP check add" )
log.debug("IBTS PiP check add")
return gInfoBarTunerState.addEntry("PiP", self.getPluginName(), self.getType(), self.getText())
return None

Expand All @@ -71,48 +71,48 @@ def onShow(self, tunerstates):
self.tunerstate = self.checkPiP()
else:
from Screens.InfoBar import InfoBar
if InfoBar.instance and InfoBar.instance.session and hasattr(InfoBar.instance.session, "pip")==False:
if InfoBar.instance and InfoBar.instance.session and hasattr(InfoBar.instance.session, "pip") == False:
from Plugins.Extensions.InfoBarTunerState.plugin import gInfoBarTunerState
if gInfoBarTunerState:
gInfoBarTunerState.finishEntry("PiP")

def update(self, id, tunerstate):
if config.infobartunerstate.plugin_pip.enabled.value:

remove = True

if tunerstate:

from Screens.InfoBar import InfoBar
if InfoBar.instance and InfoBar.instance.session:

if hasattr(InfoBar.instance.session, "pip"):

pip = InfoBar.instance.session.pip

eservicereference = None
if hasattr(pip, "currentService"):
if hasattr(pip, "currentService"):
eservicereference = pip.currentService

if eservicereference:
log.debug( "IBTS PiP update service" )
log.debug("IBTS PiP update service")

remove = False
changed = False

eservicereference_string = str(eservicereference)

# Avoid recalculations
if self.eservicereference_string != eservicereference_string:
tunerstate.number = None
tunerstate.channel = ""
tunerstate.reference = ""

tunerstate.tuner, tunerstate.tunertype, tunerstate.tunernumber = "", "", None
tunerstate.name, tunerstate.begin, tunerstate.end = "", 0, 0

self.eservicereference_string = eservicereference_string

if not tunerstate.number:
tunerstate.number = getNumber(eservicereference)
changed = True
Expand All @@ -124,34 +124,34 @@ def update(self, id, tunerstate):
tunerstate.reference = str(ServiceReference(eservicereference))
tunerstate.updatePicon()
changed = True

iplayableservice = None
if hasattr(pip, "pipservice"):
iplayableservice = pip.pipservice
#if hasattr(pip, "getCurrentServiceReference"):
# iplayableservice = pip.getCurrentServiceReference()
log.debug( "IBTS PiP update iPlay", str(iplayableservice) )

log.debug("IBTS PiP update iPlay", str(iplayableservice))
if iplayableservice:
if not tunerstate.tuner or not tunerstate.tunertype or not tunerstate.tunernumber:
tunerstate.tuner, tunerstate.tunertype, tunerstate.tunernumber = getTunerByPlayableService(iplayableservice)
changed = True

if not tunerstate.name or not tunerstate.begin or not tunerstate.end:
tunerstate.name, tunerstate.begin, tunerstate.end = getEventData(iplayableservice)
changed = True

if changed:
from Plugins.Extensions.InfoBarTunerState.plugin import gInfoBarTunerState
if gInfoBarTunerState:
gInfoBarTunerState.updateMetrics()

if remove:

from Plugins.Extensions.InfoBarTunerState.plugin import gInfoBarTunerState
if gInfoBarTunerState:
gInfoBarTunerState.finishEntry(id)
return False

else:
return True
Loading