Screens: small optimization- change find to in
authorTaapat <taapat@gmail.com>
Sat, 26 Oct 2013 18:54:14 +0000 (21:54 +0300)
committerMirakels <mirakels@openpli.org>
Sun, 27 Oct 2013 14:31:33 +0000 (15:31 +0100)
Signed-off-by: Mirakels <mirakels@openpli.org>

lib/python/Screens/ChannelSelection.py
lib/python/Screens/Dish.py
lib/python/Screens/InputBox.py
lib/python/Screens/MovieSelection.py
lib/python/Screens/ScanSetup.py
lib/python/Screens/Wizard.py
po/xml2po.py

index 0e6a0f8..f2ae52f 100644 (file)
@@ -119,7 +119,7 @@ class ChannelContextMenu(Screen):
                current_root = csel.getRoot()
                current_sel_path = current.getPath()
                current_sel_flags = current.flags
-               inBouquetRootList = current_root and current_root.getPath().find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
+               inBouquetRootList = current_root and 'FROM BOUQUET "bouquets.' in current_root.getPath() #FIXME HACK
                inBouquet = csel.getMutableList() is not None
                haveBouquets = config.usage.multibouquet.value
 
@@ -160,17 +160,17 @@ class ChannelContextMenu(Screen):
                                                        else:
                                                                append_when_current_valid(current, menu, (_("play in mainwindow"), self.playMain), level = 0)
                                else:
-                                       if current_root.getPath().find('FROM SATELLITES') != -1:
+                                       if 'FROM SATELLITES' in current_root.getPath():
                                                append_when_current_valid(current, menu, (_("remove selected satellite"), self.removeSatelliteServices), level = 0)
                                        if haveBouquets:
-                                               if not inBouquet and current_sel_path.find("PROVIDERS") == -1:
+                                               if not inBouquet and not "PROVIDERS" in current_sel_path:
                                                        append_when_current_valid(current, menu, (_("copy to bouquets"), self.copyCurrentToBouquetList), level = 0)
-                                       if current_sel_path.find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
+                                       if ("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) in current_sel_path:
                                                append_when_current_valid(current, menu, (_("remove all new found flags"), self.removeAllNewFoundFlags), level = 0)
                                if inBouquet:
                                        append_when_current_valid(current, menu, (_("rename entry"), self.renameEntry), level = 0)                                      
                                        append_when_current_valid(current, menu, (_("remove entry"), self.removeCurrentService), level = 0)
-                               if current_root and current_root.getPath().find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
+                               if current_root and ("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) in current_root.getPath():
                                        append_when_current_valid(current, menu, (_("remove new found flag"), self.removeNewFoundFlag), level = 0)
                        else:
                                        menu.append(ChoiceEntryComponent(text = (_("add bouquet"), self.showBouquetInputBox)))
@@ -959,7 +959,7 @@ class ChannelSelectionBase(Screen):
                if self.startRoot is None:
                        self.startRoot = self.getRoot()
                path = root.getPath()
-               inBouquetRootList = path.find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
+               inBouquetRootList = 'FROM BOUQUET "bouquets.' in path #FIXME HACK
                pos = path.find('FROM BOUQUET')
                isBouquet = (pos != -1) and (root.flags & eServiceReference.isDirectory)
                if not inBouquetRootList and isBouquet:
@@ -1095,9 +1095,9 @@ class ChannelSelectionBase(Screen):
                                                        orbpos = service.getData(4) >> 16
                                                        if orbpos < 0:
                                                                orbpos += 3600
-                                                       if service.getPath().find("FROM PROVIDER") != -1:
+                                                       if "FROM PROVIDER" in service.getPath():
                                                                service_type = _("Providers")
-                                                       elif service.getPath().find("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) != -1:
+                                                       elif ("flags == %d" %(FLAG_SERVICE_NEW_FOUND)) in service.getPath():
                                                                service_type = _("New")
                                                        else:
                                                                service_type = _("Services")
@@ -1324,7 +1324,7 @@ class ChannelSelectionBase(Screen):
 
        def gotoCurrentServiceOrProvider(self, ref):
                str = ref.toString()
-               if str.find(_("Providers")) != -1:
+               if _("Providers") in str:
                        service = self.session.nav.getCurrentService()
                        if service:
                                info = service.info()
@@ -1655,7 +1655,7 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit, ChannelSelect
        def preEnterPath(self, refstr):
                if self.servicePath and self.servicePath[0] != eServiceReference(refstr):
                        pathstr = self.lastroot.value
-                       if pathstr is not None and pathstr.find(refstr) == 0:
+                       if pathstr is not None and refstr in pathstr:
                                self.restoreRoot()
                                lastservice = eServiceReference(self.lastservice.value)
                                if lastservice.valid():
@@ -1857,7 +1857,7 @@ class ChannelSelectionRadio(ChannelSelectionBase, ChannelSelectionEdit, ChannelS
        def preEnterPath(self, refstr):
                if self.servicePathRadio and self.servicePathRadio[0] != eServiceReference(refstr):
                        pathstr = config.radio.lastroot.value
-                       if pathstr is not None and pathstr.find(refstr) == 0:
+                       if pathstr is not None and refstr in pathstr:
                                self.restoreRoot()
                                lastservice = eServiceReference(config.radio.lastservice.value)
                                if lastservice.valid():
index e6afb90..0b8adbc 100644 (file)
@@ -120,7 +120,7 @@ class Dish(Screen):
                        return
 
                tuner_type = data.get("tuner_type")
-               if tuner_type and tuner_type.find("DVB-S") != -1:
+               if tuner_type and "DVB-S" in tuner_type:
                        self.cur_orbpos = data.get("orbital_position", INVALID_POSITION)
                        if self.cur_orbpos != INVALID_POSITION:
                                config.misc.lastrotorposition.value = self.cur_orbpos
index 81884e6..9e4139f 100644 (file)
@@ -128,7 +128,7 @@ class PinInput(InputBox):
                        InputBox.keyNumberGlobal(self, number)
                
        def checkPin(self, pin):
-               if pin is not None and pin.find(" ") == -1 and int(pin) in self.pinList:
+               if pin is not None and " " not in pin and int(pin) in self.pinList:
                        return True
                return False
                
index 846fc8f..56c7449 100644 (file)
@@ -1657,7 +1657,7 @@ class MovieSelection(Screen, HelpableScreen, SelectionEventInfo, InfoBarBase):
                                rec_filename = os.path.split(current.getPath())[1]
                                if rec_filename.endswith(".ts"): rec_filename = rec_filename[:-3]
                                for timer in NavigationInstance.instance.RecordTimer.timer_list:
-                                       if timer.isRunning() and not timer.justplay and timer.Filename.find(rec_filename)>=0:
+                                       if timer.isRunning() and not timer.justplay and rec_filename in timer.Filename:
                                                choices = [
                                                        (_("Cancel"), None),
                                                        (_("Stop recording"), ("s", timer)),
index 478932b..f9d4b7e 100644 (file)
@@ -397,13 +397,13 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
                                print self.scan_satselection[index_to_scan]
                                self.list.append(getConfigListEntry(_("Satellite"), self.scan_satselection[index_to_scan]))
                                self.scan_networkScan.value = True
-                       elif self.scan_type.value.find("multisat") != -1:
+                       elif "multisat" in self.scan_type.value:
                                tlist = []
                                SatList = nimmanager.getSatListForNim(index_to_scan)
                                for x in SatList:
                                        if self.Satexists(tlist, x[0]) == 0:
                                                tlist.append(x[0])
-                                               sat = ConfigEnableDisable(default = self.scan_type.value.find("_yes") != -1 and True or False)
+                                               sat = ConfigEnableDisable(default = "_yes" in self.scan_type.value and True or False)
                                                configEntry = getConfigListEntry(nimmanager.getSatDescription(x[0]), sat)
                                                self.list.append(configEntry)
                                                self.multiscanlist.append((x[0], sat))
@@ -824,7 +824,7 @@ class ScanSetup(ConfigListScreen, Screen, CableTransponderSearchSupport):
                        elif self.scan_type.value == "single_satellite":
                                sat = self.satList[index_to_scan][self.scan_satselection[index_to_scan].index]
                                getInitialTransponderList(tlist, sat[0])
-                       elif self.scan_type.value.find("multisat") != -1:
+                       elif "multisat" in self.scan_type.value:
                                SatList = nimmanager.getSatListForNim(index_to_scan)
                                for x in self.multiscanlist:
                                        if x[1].value:
index a956418..752da93 100644 (file)
@@ -460,7 +460,7 @@ class Wizard(Screen):
                        
        def updateText(self, firstset = False):
                text = self.getTranslation(self.wizard[self.currStep]["text"])
-               if text.find("[timeout]") != -1:
+               if "[timeout]" in text:
                        text = text.replace("[timeout]", str(self.timeoutCounter))
                        self["text"].setText(text)
                else:
index 273e20a..7eeebc2 100755 (executable)
@@ -21,7 +21,7 @@ class parseXML(ContentHandler, LexicalHandler):
                self.ishex = re.compile('#[0-9a-fA-F]+\Z')
 
        def comment(self, comment):
-               if comment.find("TRANSLATORS:") != -1:
+               if "TRANSLATORS:" in comment:
                        self.last_comment = comment
 
        def startElement(self, name, attrs):