From: Moritz Venn Date: Sun, 1 Mar 2009 00:44:23 +0000 (+0000) Subject: smaller cleanups, X-Git-Url: http://code.vuplus.com/gitweb/?a=commitdiff_plain;h=7bc531db2d75682b3f3ffe2f05feaf7a223667b4;p=vuplus_dvbapp-plugin smaller cleanups, remove trailing whitespaces --- diff --git a/ac3lipsync/src/AC3delay.py b/ac3lipsync/src/AC3delay.py index 0d67826..c68f6c0 100644 --- a/ac3lipsync/src/AC3delay.py +++ b/ac3lipsync/src/AC3delay.py @@ -5,8 +5,7 @@ from Tools.ISO639 import LanguageCodes import os import NavigationInstance -class AC3delay(): - +class AC3delay: def __init__(self, session): self.iService = None self.iServiceReference = None @@ -19,22 +18,21 @@ class AC3delay(): self.lamedbDelay = {} self.getAudioInformation() - + # Current value for movie start behaviour self.movieStart = config.usage.on_movie_start.getValue() - - + def initAudio(self): self.iService = NavigationInstance.instance.getCurrentService() self.iServiceReference = NavigationInstance.instance.getCurrentlyPlayingServiceReference() self.iAudioDelay = self.iService and self.iService.audioDelay() self.iSeek = self.iService and self.iService.seek() - + def deleteAudio(self): self.iService = None self.iAudioDelay = None self.iSeek = None - + def setChannelAudio(self, sAudio): self.channelAudio = sAudio @@ -58,14 +56,14 @@ class AC3delay(): self.timer.start(400, False) else: self.deleteAudio() - + def seekAfterWait(self): self.timer.stop() self.initAudio() if self.iSeek is not None: self.iSeek.seekTo(self.lCurPosition) self.deleteAudio() - + def cueGetCurrentPosition(self): if self.iSeek is None: return None @@ -90,7 +88,7 @@ class AC3delay(): if bInitialized == True: self.deleteAudio() return iDelay - + def getFileDelay(self, sAudio): sFileName = lFileDelay[sAudio] if os.path.exists(sFileName) == True: @@ -113,7 +111,7 @@ class AC3delay(): else: self.iAudioDelay.setPCMDelay(iDelay) self.activateDelay() - + def setFileDelay(self, sAudio, iDelay): hDelay = dec2hex(iDelay*90) sFileName = lFileDelay[sAudio] @@ -122,7 +120,7 @@ class AC3delay(): delayfile.write("%s\0" % hDelay) delayfile.close() self.activateDelay() - + def getAudioInformation(self): bInitialized = False if self.iService == None: @@ -165,3 +163,4 @@ class AC3delay(): del oAudioTracks if bInitialized == True: self.deleteAudio() + diff --git a/ac3lipsync/src/AC3main.py b/ac3lipsync/src/AC3main.py index a8320ad..b5690e5 100644 --- a/ac3lipsync/src/AC3main.py +++ b/ac3lipsync/src/AC3main.py @@ -14,7 +14,7 @@ from Screens.InfoBarGenerics import InfoBarAudioSelection from ServiceReference import ServiceReference from __init__ import _ import os - + class AC3LipSync(Screen,InfoBarAudioSelection): skin = """ @@ -29,9 +29,9 @@ class AC3LipSync(Screen,InfoBarAudioSelection): - + - + @@ -49,13 +49,11 @@ class AC3LipSync(Screen,InfoBarAudioSelection): font="Regular;16" valign="center" halign="left" transparent="1" shadowColor="#000000" shadowOffset="-1,-1" /> """ - + def __init__(self, session, args = None): Screen.__init__(self, session) self.onShow.append(self.__onShow) - self.session = session - #Initialisiere Infobargenerics InfoBarAudioSelection.__init__(self) @@ -67,17 +65,17 @@ class AC3LipSync(Screen,InfoBarAudioSelection): # AC3delay instance self.AC3delay = AC3delay(self.session) - + #Which Values do the number keys use (not implemented yet) self.whichKeys = "Computed" # Computed = computed Values of keys, User = User set values of keys self.whichKeyText = {} self.whichKeyText["Computed"] = _("Use user delays") self.whichKeyText["User"] = _("Use calc. delays") - + #Screen elements - + #Slider - + for sAudio in AC3PCM: self[sAudio+"Slider"] = ProgressBar() self[sAudio+"SliderText"] = Label(_("%i ms")%0) @@ -87,14 +85,14 @@ class AC3LipSync(Screen,InfoBarAudioSelection): #Service Information self["ServiceInfoText"] = Label(_("Channel audio:")) - self["ServiceInfo"] = Label() + self["ServiceInfo"] = Label() self.setChannelInfoText() - + # Buttons if self.AC3delay.bIsRecording == True: self["key_red"] = Label(_(" ")) else: - self["key_red"] = Label(_("Save")) + self["key_red"] = Label(_("Save")) self["key_green"] = Label(_("Switch audio")) self["key_yellow"] = Label(_("Set user delay")) self["key_blue"] = Label(self.whichKeyText[self.whichKeys]) @@ -103,14 +101,14 @@ class AC3LipSync(Screen,InfoBarAudioSelection): self.savedValue = {} self.savedValue[AC3] = 0 self.savedValue[PCM] = 0 - + # Current Values self.currentValue = {} self.currentValue[AC3] = 0 self.currentValue[PCM] = 0 - + # Actions - self["actions"] = NumberActionMap(["WizardActions", "NumberActions", "ColorActions"] , + self["actions"] = NumberActionMap(["WizardActions", "NumberActions", "ColorActions"], { "ok": self.keyOk, "back": self.keyCancel, @@ -148,7 +146,7 @@ class AC3LipSync(Screen,InfoBarAudioSelection): else: self["AC3DelayText"].setForegroundColorNum(0) self["PCMDelayText"].setForegroundColorNum(1) - + def keyUp(self): self.AC3delay.whichAudio = AC3 self["AC3DelayText"].setForegroundColorNum(1) @@ -158,7 +156,7 @@ class AC3LipSync(Screen,InfoBarAudioSelection): self.AC3delay.whichAudio = PCM self["AC3DelayText"].setForegroundColorNum(0) self["PCMDelayText"].setForegroundColorNum(1) - + def keyLeft(self): sAudio = self.AC3delay.whichAudio iSliderValue = int(self[sAudio+"Slider"].getValue()) @@ -167,7 +165,7 @@ class AC3LipSync(Screen,InfoBarAudioSelection): iSliderValue = 0 self.setSliderInfo(iSliderValue) self.AC3delay.setFileDelay(sAudio, self.currentValue[sAudio]) - + def keyRight(self): sAudio = self.AC3delay.whichAudio iSliderValue = int(self[sAudio+"Slider"].getValue()) @@ -197,10 +195,10 @@ class AC3LipSync(Screen,InfoBarAudioSelection): def keyAudioSelection(self): self.audioSelection() - + def keyOk(self): self.close() - + def keyCancel(self): for sAudio in lFileDelay.keys(): iSliderValue = self.currentValue[sAudio] @@ -208,16 +206,17 @@ class AC3LipSync(Screen,InfoBarAudioSelection): self.whichAudio = sAudio self.AC3delay.setFileDelay(sAudio, self.savedValue[sAudio]) self.close() - + def keySaveToLamedb(self): if self.AC3delay.bIsRecording == False: - keyList = [] - keyList.append((_("Save %s delay")%AC3,"1")) - keyList.append((_("Save %s delay")%PCM,"2")) - keyList.append((_("Save both delays"),"3")) - + keyList = [ + (_("Save %s delay")%AC3,"1"), + (_("Save %s delay")%PCM,"2"), + (_("Save both delays"),"3") + ] + self.session.openWithCallback(self.DoSaveLamedb,ChoiceBox,_("Which delays do you want to set"),keyList) - + def DoSaveLamedb(self, answer): sNewLine = "" sResponse = "" @@ -274,31 +273,30 @@ class AC3LipSync(Screen,InfoBarAudioSelection): sActiveAudio = str(self.AC3delay.selectedAudioInfo[0]) sBitstreamDelay = _("%i ms") %self.AC3delay.lamedbDelay[AC3] sPCMDelay = ("%i ms") %self.AC3delay.lamedbDelay[PCM] - + self["ServiceInfo"].setText(sActiveAudio) self["AC3DelayInfo"].setText(sBitstreamDelay) self["PCMDelayInfo"].setText(sPCMDelay) - + def keySwitchKeyValues(self): if self.whichKeys == "Computed": self.whichKeys = "User" else: self.whichKeys = "Computed" self["key_blue"].setText(self.whichKeyText[self.whichKeys]) - + def keySaveDelayToKey(self): sAudio = self.AC3delay.whichAudio iDelay = self[sAudio+"Slider"].getValue()+self.lowerBound AC3SetCustomValue(self.session,iDelay) - + def audioSelected(self, audio): InfoBarAudioSelection.audioSelected(self, audio) if audio is not None: self.AC3delay.getAudioInformation() self.setChannelInfoText() - -class AC3SetCustomValue(Screen): +class AC3SetCustomValue: def __init__(self, session, iDelay): self.session = session self.iDelay = iDelay @@ -312,8 +310,9 @@ class AC3SetCustomValue(Screen): def DoSetCustomValue(self,answer): if answer is None: - self.session.open(MessageBox,_("Setting key canceled"), MessageBox.TYPE_INFO) + self.session.open(MessageBox,_("Setting key canceled"), MessageBox.TYPE_INFO) else: config.plugins.AC3LipSync.keySteps[int(answer[1])].stepSize.setValue(self.iDelay) config.plugins.AC3LipSync.keySteps.save() - self.session.open(MessageBox,_("%(Key)s successfully set to %(delay)i ms") %dict(Key=answer[0],delay=self.iDelay), MessageBox.TYPE_INFO, 5) \ No newline at end of file + self.session.open(MessageBox,_("%(Key)s successfully set to %(delay)i ms") %dict(Key=answer[0],delay=self.iDelay), MessageBox.TYPE_INFO, 5) + diff --git a/ac3lipsync/src/AC3setup.py b/ac3lipsync/src/AC3setup.py index 1ad47e8..1fb1b51 100644 --- a/ac3lipsync/src/AC3setup.py +++ b/ac3lipsync/src/AC3setup.py @@ -36,15 +36,16 @@ class AC3LipSyncSetup(ConfigListScreen, Screen): def __init__(self, session, args = None): Screen.__init__(self, session) - + # nun erzeugen wir eine liste von elementen fuer die menu liste. - self.list = [ ] - self.list.append(getConfigListEntry(_("Minimum delay"), config.plugins.AC3LipSync.lowerBound)) - self.list.append(getConfigListEntry(_("Maximum delay"), config.plugins.AC3LipSync.upperBound)) - self.list.append(getConfigListEntry(_("Step in ms for arrow keys"), config.plugins.AC3LipSync.arrowStepSize)) + self.list = [ + getConfigListEntry(_("Minimum delay"), config.plugins.AC3LipSync.lowerBound), + getConfigListEntry(_("Maximum delay"), config.plugins.AC3LipSync.upperBound), + getConfigListEntry(_("Step in ms for arrow keys"), config.plugins.AC3LipSync.arrowStepSize) + ] for i in range(1 , 10): self.list.append(getConfigListEntry(_("Step in ms for key %i" %i), config.plugins.AC3LipSync.keySteps[i].stepSize)) - + ConfigListScreen.__init__(self, self.list) self["config"].list = self.list @@ -53,7 +54,7 @@ class AC3LipSyncSetup(ConfigListScreen, Screen): self["key_red"] = Button(_("Cancel")) self["key_green"] = Button(_("Save")) self["key_yellow"] = Button(_("Recalculate...")) - self["key_blue"] = Button(_(" ")) + self["key_blue"] = Button(" ") self["setupActions"] = NumberActionMap(["SetupActions", "ColorActions"], { @@ -72,7 +73,7 @@ class AC3LipSyncSetup(ConfigListScreen, Screen): for i in range(1 , 10): config.plugins.AC3LipSync.keySteps[i].stepSize.setValue(i*iStepSize) self["config"].setList(self.list) - + def save(self): iLowerBound = int(config.plugins.AC3LipSync.lowerBound.getValue()) iUpperBound = int(config.plugins.AC3LipSync.upperBound.getValue()) @@ -90,7 +91,3 @@ class AC3LipSyncSetup(ConfigListScreen, Screen): x[1].cancel() self.close() - def startPlugin(self): - self.save - AC3LipSync(self.session) - self.close() \ No newline at end of file diff --git a/ac3lipsync/src/AC3utils.py b/ac3lipsync/src/AC3utils.py index bcab139..514a571 100644 --- a/ac3lipsync/src/AC3utils.py +++ b/ac3lipsync/src/AC3utils.py @@ -8,8 +8,9 @@ lFileDelay[PCM] = "/proc/stb/audio/audio_delay_pcm" def dec2hex(n): """return the hexadecimal string representation of integer n""" - return "%X" % n + return "%X" % n def hex2dec(s): """return the integer value of a hexadecimal string s""" return int(s, 16) + diff --git a/ac3lipsync/src/plugin.py b/ac3lipsync/src/plugin.py index 1f23229..a0ec8aa 100644 --- a/ac3lipsync/src/plugin.py +++ b/ac3lipsync/src/plugin.py @@ -11,25 +11,26 @@ config.plugins.AC3LipSync.arrowStepSize = ConfigInteger(default = 5, limits = (0 config.plugins.AC3LipSync.stepSize = ConfigInteger(default = 45, limits = (0,10000)) config.plugins.AC3LipSync.keySteps = ConfigSubList() for i in range(0, 10): - s = ConfigSubsection() + s = ConfigSubsection() s.stepSize = ConfigInteger(default = i*45, limits = (0,10000)) config.plugins.AC3LipSync.keySteps.append(s) del s - + def main(session, **kwargs): # reload(AC3main) session.open(AC3main.AC3LipSync) - + def setup(session, **kwargs): # reload(AC3setup) session.open(AC3setup.AC3LipSyncSetup) def mainSetup(menuid, **kwargs): - if menuid == "setup": + if menuid == "setup": return [(_("AC3 Lip Sync"), main, "ac3_lipsync", 99)] return [ ] def Plugins(**kwargs): - return [ PluginDescriptor(name=_("AC3 Lip Sync"), description=_("sets the AC3 audio Delay (LipSync)"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=main), + return [ PluginDescriptor(name=_("AC3 Lip Sync"), description=_("sets the AC3 audio Delay (LipSync)"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=main), PluginDescriptor(name=_("AC3 Lip Sync Setup"), description=_("Setup for the AC3 Lip Sync Plugin"), icon = "AC3LipSync.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=setup), - PluginDescriptor(name=_("AC3 Lip Sync"), description=_("sets the AC3 audio Delay (LipSync)"), where = PluginDescriptor.WHERE_MENU, fnc=mainSetup)] \ No newline at end of file + PluginDescriptor(name=_("AC3 Lip Sync"), description=_("sets the AC3 audio Delay (LipSync)"), where = PluginDescriptor.WHERE_MENU, fnc=mainSetup)] +