Fixed some loop related coding issues detected by the extended code style checker.

Tue, 13 Mar 2018 14:54:46 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 13 Mar 2018 14:54:46 +0100
changeset 6188
5a6ae3be31e6
parent 6187
2cc7e3629784
child 6192
0fbc876d7468

Fixed some loop related coding issues detected by the extended code style checker.

PluginManager/PluginManager.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleFixer.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/CodeStyleChecker/DocStyleChecker.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckService.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/SyntaxChecker/jsCheckSyntax.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/Tabnanny/Tabnanny.py file | annotate | diff | comparison | revisions
Plugins/DocumentationPlugins/Ericapi/EricapiConfigDialog.py file | annotate | diff | comparison | revisions
Plugins/DocumentationPlugins/Ericdoc/EricdocConfigDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsGit/GitDiffHighlighter.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsPySvn/SvnRepoBrowserDialog.py file | annotate | diff | comparison | revisions
Plugins/VcsPlugins/vcsPySvn/SvnTagBranchListDialog.py file | annotate | diff | comparison | revisions
Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py file | annotate | diff | comparison | revisions
Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.py file | annotate | diff | comparison | revisions
Plugins/WizardPlugins/SetupWizard/SetupWizardDialog.py file | annotate | diff | comparison | revisions
Preferences/ConfigurationDialog.py file | annotate | diff | comparison | revisions
Project/Project.py file | annotate | diff | comparison | revisions
Project/QuickFindFileDialog.py file | annotate | diff | comparison | revisions
Project/UserPropertiesDialog.py file | annotate | diff | comparison | revisions
QScintilla/Editor.py file | annotate | diff | comparison | revisions
QScintilla/EditorAssembly.py file | annotate | diff | comparison | revisions
QScintilla/QsciScintillaCompat.py file | annotate | diff | comparison | revisions
UI/NumbersWidget.py file | annotate | diff | comparison | revisions
UI/UserInterface.py file | annotate | diff | comparison | revisions
Utilities/BackgroundService.py file | annotate | diff | comparison | revisions
Utilities/binplistlib.py file | annotate | diff | comparison | revisions
Utilities/crypto/py3AES.py file | annotate | diff | comparison | revisions
Utilities/crypto/py3PBKDF2.py file | annotate | diff | comparison | revisions
VCS/ProjectHelper.py file | annotate | diff | comparison | revisions
VCS/__init__.py file | annotate | diff | comparison | revisions
uninstall-debugclients.py file | annotate | diff | comparison | revisions
uninstall.py file | annotate | diff | comparison | revisions
--- a/PluginManager/PluginManager.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/PluginManager/PluginManager.py	Tue Mar 13 14:54:46 2018 +0100
@@ -883,9 +883,8 @@
         """
         pluginDict = {}
         
-        for _name, module in \
-            list(self.__onDemandActiveModules.items()) + \
-                list(self.__onDemandInactiveModules.items()):
+        for module in list(self.__onDemandActiveModules.values()) + \
+                list(self.__onDemandInactiveModules.values()):
             if getattr(module, "pluginType") == type_ and \
                getattr(module, "error", "") == "":
                 plugin_name = getattr(module, "pluginTypename")
@@ -909,9 +908,8 @@
         @param name name of the plugin type (string)
         @return preview pixmap (QPixmap)
         """
-        for _modname, module in \
-            list(self.__onDemandActiveModules.items()) + \
-                list(self.__onDemandInactiveModules.items()):
+        for module in list(self.__onDemandActiveModules.values()) + \
+                list(self.__onDemandInactiveModules.values()):
             if getattr(module, "pluginType") == type_ and \
                getattr(module, "pluginTypename") == name:
                 if hasattr(module, "previewPix"):
@@ -1089,9 +1087,8 @@
         """
         vcsDict = {}
         
-        for _name, module in \
-            list(self.__onDemandActiveModules.items()) + \
-                list(self.__onDemandInactiveModules.items()):
+        for module in list(self.__onDemandActiveModules.values()) + \
+                list(self.__onDemandInactiveModules.values()):
             if getattr(module, "pluginType") == "version_control":
                 if hasattr(module, "getVcsSystemIndicator"):
                     res = module.getVcsSystemIndicator()
@@ -1350,11 +1347,11 @@
         
         @param type_ type of the plugin to clear private data for (string)
         """
-        for _name, module in \
-            list(self.__onDemandActiveModules.items()) + \
-            list(self.__onDemandInactiveModules.items()) + \
-            list(self.__activeModules.items()) + \
-                list(self.__inactiveModules.items()):
+        for module in \
+            list(self.__onDemandActiveModules.values()) + \
+            list(self.__onDemandInactiveModules.values()) + \
+            list(self.__activeModules.values()) + \
+                list(self.__inactiveModules.values()):
             if getattr(module, "pluginType", "") == type_:
                 if hasattr(module, "clearPrivateData"):
                     module.clearPrivateData()
--- a/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleChecker.py	Tue Mar 13 14:54:46 2018 +0100
@@ -187,7 +187,7 @@
         taskQueue.put(task)
 
     # Start worker processes
-    for i in range(NumberOfProcesses):
+    for _ in range(NumberOfProcesses):
         multiprocessing.Process(target=worker, args=(taskQueue, doneQueue))\
             .start()
 
@@ -217,7 +217,7 @@
             taskQueue.put(argumentsList[i + initialTasks])
 
     # Tell child processes to stop
-    for i in range(NumberOfProcesses):
+    for _ in range(NumberOfProcesses):
         taskQueue.put('STOP')
 
 
@@ -322,7 +322,7 @@
         errors += complexityChecker.errors
     
     errorsDict = {}
-    for fname, lineno, position, text in errors:
+    for _fname, lineno, position, text in errors:
         if lineno > len(source):
             lineno = len(source)
         # inverse processing of messages and fixes
--- a/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleCheckerDialog.py	Tue Mar 13 14:54:46 2018 +0100
@@ -668,8 +668,8 @@
         fixed = None
         ignoredErrors = 0
         if self.__itms:
-            for itm, (lineno, position, text, ignored, fixed, autofixing) in \
-                    zip(self.__itms, results):
+            for itm, (_lineno, _position, text, _ignored, fixed,
+                      _autofixing) in zip(self.__itms, results):
                 self.__modifyFixedResultItem(itm, text, fixed)
             self.__updateFixerStatistics(fixes)
         else:
--- a/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleFixer.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleFixer.py	Tue Mar 13 14:54:46 2018 +0100
@@ -1238,7 +1238,7 @@
         tokens = '<>*/=^&|%!+-'
         pos2 = pos
         token_delimiter = len(tokens)
-        for i in range(3):
+        for _ in range(3):
             if pos2 < len(text) and text[pos2] in tokens[:token_delimiter]:
                 pos2 += 1
                 # only the first five could be repeated
--- a/Plugins/CheckerPlugins/CodeStyleChecker/DocStyleChecker.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/DocStyleChecker.py	Tue Mar 13 14:54:46 2018 +0100
@@ -508,7 +508,7 @@
         @param source source to parse (list of string)
         @return context of extracted docstring (DocStyleContext)
         """
-        for kind, value, (line, char), _, _ in tokenize.generate_tokens(
+        for kind, value, (line, _char), _, _ in tokenize.generate_tokens(
                 StringIO("".join(source)).readline):
             if kind in [tokenize.COMMENT, tokenize.NEWLINE, tokenize.NL]:
                 continue
--- a/Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/MiscellaneousChecker.py	Tue Mar 13 14:54:46 2018 +0100
@@ -507,7 +507,7 @@
         implicit = False
         explicit = False
         try:
-            for literal, field, spec, conv in self.Formatter.parse(string):
+            for _literal, field, spec, conv in self.Formatter.parse(string):
                 if field is not None and (conv is None or conv in 'rsa'):
                     if not field:
                         field = str(next(cnt))
--- a/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheck.py	Tue Mar 13 14:54:46 2018 +0100
@@ -163,7 +163,7 @@
         taskQueue.put(task)
 
     # Start worker processes
-    for i in range(NumberOfProcesses):
+    for _ in range(NumberOfProcesses):
         multiprocessing.Process(target=worker, args=(taskQueue, doneQueue))\
             .start()
 
@@ -193,7 +193,7 @@
             taskQueue.put(argumentsList[i + initialTasks])
 
     # Tell child processes to stop
-    for i in range(NumberOfProcesses):
+    for _ in range(NumberOfProcesses):
         taskQueue.put('STOP')
 
 
--- a/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckService.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckService.py	Tue Mar 13 14:54:46 2018 +0100
@@ -57,7 +57,8 @@
         if pyVer:
             return 'Python{0}'.format(pyVer)
         
-        for lang, (env, getArgs, getExt) in self.__supportedLanguages.items():
+        for lang, (_env, _getArgs, getExt) in \
+                self.__supportedLanguages.items():
             if filename.endswith(tuple(getExt())):
                 return lang
         
@@ -112,7 +113,7 @@
         @return set of all supported file extensions (set of str)
         """
         extensions = set()
-        for env, getArgs, getExt in self.__supportedLanguages.values():
+        for _env, _getArgs, getExt in self.__supportedLanguages.values():
             for ext in getExt():
                 extensions.add(ext)
         return extensions
--- a/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py	Tue Mar 13 14:54:46 2018 +0100
@@ -357,7 +357,7 @@
                     source = ""
             else:
                 source = self.source.splitlines()
-            for _fn, lineno, col, code, msg in warnings:
+            for filename, lineno, col, _code, msg in warnings:
                 self.noResults = False
                 if source:
                     try:
@@ -366,7 +366,8 @@
                         scr_line = ""
                 else:
                     scr_line = ""
-                self.__createResultItem(_fn, lineno, col, msg, scr_line, True)
+                self.__createResultItem(filename, lineno, col, msg, scr_line,
+                                        True)
 
         self.progress += 1
         self.checkProgress.setValue(self.progress)
--- a/Plugins/CheckerPlugins/SyntaxChecker/jsCheckSyntax.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/CheckerPlugins/SyntaxChecker/jsCheckSyntax.py	Tue Mar 13 14:54:46 2018 +0100
@@ -27,7 +27,7 @@
     @return the entry point for the background client (function)
     """
     path = __file__
-    for i in range(4):
+    for _ in range(4):
         path = os.path.dirname(path)
     sys.path.insert(2, os.path.join(path, "ThirdParty", "Jasy"))
     return jsSyntaxCheck
@@ -114,7 +114,7 @@
         taskQueue.put(task)
 
     # Start worker processes
-    for i in range(NumberOfProcesses):
+    for _ in range(NumberOfProcesses):
         multiprocessing.Process(target=worker, args=(taskQueue, doneQueue))\
             .start()
 
@@ -144,7 +144,7 @@
             taskQueue.put(argumentsList[i + initialTasks])
 
     # Tell child processes to stop
-    for i in range(NumberOfProcesses):
+    for _ in range(NumberOfProcesses):
         taskQueue.put('STOP')
 
 
--- a/Plugins/CheckerPlugins/Tabnanny/Tabnanny.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/CheckerPlugins/Tabnanny/Tabnanny.py	Tue Mar 13 14:54:46 2018 +0100
@@ -171,7 +171,7 @@
         taskQueue.put(task)
 
     # Start worker processes
-    for i in range(NumberOfProcesses):
+    for _ in range(NumberOfProcesses):
         multiprocessing.Process(target=worker, args=(taskQueue, doneQueue))\
             .start()
 
@@ -201,7 +201,7 @@
             taskQueue.put(argumentsList[i + initialTasks])
 
     # Tell child processes to stop
-    for i in range(NumberOfProcesses):
+    for _ in range(NumberOfProcesses):
         taskQueue.put('STOP')
 
 
@@ -475,7 +475,7 @@
     indents = [Whitespace("")]
     check_equal = 0
     
-    for (tokenType, token, start, end, line) in tokens:
+    for (tokenType, token, start, _end, line) in tokens:
         if tokenType == NEWLINE:
             # a program statement, or ENDMARKER, will eventually follow,
             # after some (possibly empty) run of tokens of the form
--- a/Plugins/DocumentationPlugins/Ericapi/EricapiConfigDialog.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/DocumentationPlugins/Ericapi/EricapiConfigDialog.py	Tue Mar 13 14:54:46 2018 +0100
@@ -63,8 +63,7 @@
         
         # combine it with the values of parms
         if parms is not None:
-            for key, value in list(parms.items()):
-                self.parameters[key] = parms[key]
+            self.parameters.update(parms)
         self.parameters['outputFile'] = \
             Utilities.toNativeSeparators(self.parameters['outputFile'])
         
--- a/Plugins/DocumentationPlugins/Ericdoc/EricdocConfigDialog.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/DocumentationPlugins/Ericdoc/EricdocConfigDialog.py	Tue Mar 13 14:54:46 2018 +0100
@@ -88,7 +88,7 @@
         
         # combine it with the values of parms
         if parms is not None:
-            for key, value in list(parms.items()):
+            for key in parms:
                 if key.endswith("Color"):
                     self.colors[key] = parms[key]
                 else:
@@ -240,7 +240,7 @@
             else:
                 args.append(
                     os.path.join(self.ppath, self.parameters['cssFile']))
-        for key, value in list(self.colors.items()):
+        for key in self.colors:
             if self.colors[key] != eric6docDefaultColors[key]:
                 parms[key] = self.colors[key]
                 args.append("--{0}={1}".format(
--- a/Plugins/VcsPlugins/vcsGit/GitDiffHighlighter.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/VcsPlugins/vcsGit/GitDiffHighlighter.py	Tue Mar 13 14:54:46 2018 +0100
@@ -71,7 +71,7 @@
             @param rules set of highlighting rules (list of tuples of rule
                 pattern (string) and highlighting format (QTextCharFormat))
             """
-            for idx, ruleFormat in enumerate(rules):
+            for ruleFormat in rules:
                 rule, formats = ruleFormat
                 terminal = rule.startswith(TERMINAL(''))
                 if terminal:
--- a/Plugins/VcsPlugins/vcsPySvn/SvnRepoBrowserDialog.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/VcsPlugins/vcsPySvn/SvnRepoBrowserDialog.py	Tue Mar 13 14:54:46 2018 +0100
@@ -164,7 +164,7 @@
                 entries = self.client.list(url, recurse=False)
                 firstTime = parent == self.repoTree
                 # dirent elements are all unicode in Python 2
-                for dirent, lock in entries:
+                for dirent, _lock in entries:
                     if (firstTime and dirent["path"] != url) or \
                        (parent != self.repoTree and dirent["path"] == url):
                         continue
--- a/Plugins/VcsPlugins/vcsPySvn/SvnTagBranchListDialog.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/VcsPlugins/vcsPySvn/SvnTagBranchListDialog.py	Tue Mar 13 14:54:46 2018 +0100
@@ -137,7 +137,7 @@
         try:
             entries = self.client.list(path, recurse=False)
             # dirent, lock already unicode in Python 2
-            for dirent, lock in entries:
+            for dirent, _lock in entries:
                 if dirent["path"] != path:
                     name = dirent["path"].replace(path + '/', "")
                     self.__generateItem(dirent["created_rev"].number,
--- a/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/WizardPlugins/PyRegExpWizard/PyRegExpWizardDialog.py	Tue Mar 13 14:54:46 2018 +0100
@@ -127,7 +127,7 @@
                 steps = abs(steps)
             else:
                 act = QTextCursor.Right
-            for i in range(steps):
+            for _ in range(steps):
                 tc.movePosition(act)
         self.regexpTextEdit.setTextCursor(tc)
         
--- a/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/WizardPlugins/QRegularExpressionWizard/QRegularExpressionWizardDialog.py	Tue Mar 13 14:54:46 2018 +0100
@@ -199,7 +199,7 @@
                 steps = abs(steps)
             else:
                 act = QTextCursor.Right
-            for i in range(steps):
+            for _ in range(steps):
                 tc.movePosition(act)
         self.regexpTextEdit.setTextCursor(tc)
     
--- a/Plugins/WizardPlugins/SetupWizard/SetupWizardDialog.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Plugins/WizardPlugins/SetupWizard/SetupWizardDialog.py	Tue Mar 13 14:54:46 2018 +0100
@@ -509,7 +509,7 @@
         startDir = self.packageRootEdit.text() or self.__getStartDir()
         if startDir:
             self.packagesList.clear()
-            for dirpath, dirnames, filenames in os.walk(startDir):
+            for dirpath, _dirnames, filenames in os.walk(startDir):
                 if "__init__.py" in filenames:
                     self.__addPackage(dirpath)
         self.autodiscoverPackagesButton.setEnabled(True)
--- a/Preferences/ConfigurationDialog.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Preferences/ConfigurationDialog.py	Tue Mar 13 14:54:46 2018 +0100
@@ -855,7 +855,7 @@
         Public method called to store the selected values into the preferences
         storage.
         """
-        for key, pageData in list(self.configItems.items()):
+        for pageData in self.configItems.values():
             if pageData[-1]:
                 pageData[-1].save()
                 # page was loaded (and possibly modified)
--- a/Project/Project.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Project/Project.py	Tue Mar 13 14:54:46 2018 +0100
@@ -2337,7 +2337,7 @@
                     if os.path.exists(os.path.join(self.ppath, indicator)):
                         if len(vcsData) > 1:
                             vcsList = []
-                            for vcsSystemStr, vcsSystemDisplay in vcsData:
+                            for _vcsSystemStr, vcsSystemDisplay in vcsData:
                                 vcsList.append(vcsSystemDisplay)
                             res, vcs_ok = QInputDialog.getItem(
                                 None,
@@ -2412,10 +2412,10 @@
                 if ok and vcsSelected != self.tr("None"):
                     for vcsSystem, vcsSystemDisplay in vcsSystemsDict.items():
                         if vcsSystemDisplay == vcsSelected:
+                            self.pdata["VCS"] = vcsSystem
                             break
                     else:
-                        vcsSystem = "None"
-                    self.pdata["VCS"] = vcsSystem
+                        self.pdata["VCS"] = 'None'
                 else:
                     self.pdata["VCS"] = 'None'
                 self.vcs = self.initVCS()
@@ -2757,7 +2757,7 @@
                                     os.path.join(self.ppath, indicator)):
                                 if len(vcsData) > 1:
                                     vcsList = []
-                                    for vcsSystemStr, vcsSystemDisplay in \
+                                    for _vcsSystemStr, vcsSystemDisplay in \
                                             vcsData:
                                         vcsList.append(vcsSystemDisplay)
                                     QApplication.restoreOverrideCursor()
--- a/Project/QuickFindFileDialog.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Project/QuickFindFileDialog.py	Tue Mar 13 14:54:46 2018 +0100
@@ -215,7 +215,7 @@
         self.fileList.clear()
         locations = {}
 
-        for in_order, age, name in ordered:
+        for _in_order, _age, name in ordered:
             found = True
             QTreeWidgetItem(self.fileList, [os.path.basename(name),
                                             os.path.dirname(name)])
--- a/Project/UserPropertiesDialog.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Project/UserPropertiesDialog.py	Tue Mar 13 14:54:46 2018 +0100
@@ -47,10 +47,10 @@
         enableVcsGroup = False
         if self.project.pdata["VCS"]:
             found = False
-            for indicator, vcsData in \
+            for _indicator, vcsData in \
                     e5App().getObject("PluginManager")\
                     .getVcsSystemIndicators().items():
-                for vcsSystem, vcsSystemDisplay in vcsData:
+                for vcsSystem, _vcsSystemDisplay in vcsData:
                     if vcsSystem == self.project.pdata["VCS"]:
                         found = True
                         break
--- a/QScintilla/Editor.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/QScintilla/Editor.py	Tue Mar 13 14:54:46 2018 +0100
@@ -2174,12 +2174,12 @@
         Note: This doesn't clear the breakpoint in the debugger,
         it just deletes it from the editor internal list of breakpoints.
         
-        @param line linenumber of the breakpoint (integer)
+        @param line line number of the breakpoint (integer)
         """
         if self.inLinesChanged:
             return
         
-        for handle, (ln, _, _, _, _) in list(self.breaks.items()):
+        for handle in self.breaks:
             if self.markerLine(handle) == line - 1:
                 break
         else:
@@ -2218,7 +2218,7 @@
         @param line line number of the breakpoint (integer)
         @param temporary flag indicating a temporary breakpoint (boolean)
         """
-        for handle, (ln, _, _, _, _) in list(self.breaks.items()):
+        for handle in self.breaks:
             if self.markerLine(handle) == line - 1:
                 # delete breakpoint or toggle it to the next state
                 index = self.breakpointModel.getBreakPointIndex(
@@ -2253,16 +2253,13 @@
         
         @param line line number of the breakpoint (integer)
         """
-        for handle, (ln, cond, temp, enabled, ignorecount) in \
-                self.breaks.items():
+        for handle in self.breaks:
             if self.markerLine(handle) == line - 1:
+                index = self.breakpointModel.getBreakPointIndex(
+                    self.fileName, line)
+                self.breakpointModel.setBreakPointEnabledByIndex(
+                    index, not self.breaks[handle][3])
                 break
-        else:
-            # no breakpoint found on that line
-            return
-        
-        index = self.breakpointModel.getBreakPointIndex(self.fileName, line)
-        self.breakpointModel.setBreakPointEnabledByIndex(index, not enabled)
         
     def curLineHasBreakpoint(self):
         """
@@ -2340,28 +2337,25 @@
             self.line = line - 1
         if self.line < 0:
             self.line, index = self.getCursorPosition()
-        found = False
-        for handle, (ln, cond, temp, enabled, ignorecount) in \
-                self.breaks.items():
+        
+        for handle in self.breaks:
             if self.markerLine(handle) == self.line:
-                found = True
-                break
-        
-        if found:
-            index = self.breakpointModel.getBreakPointIndex(self.fileName, ln)
-            if not index.isValid():
-                return
-            
-            from Debugger.EditBreakpointDialog import EditBreakpointDialog
-            dlg = EditBreakpointDialog(
-                (self.fileName, ln),
-                (cond, temp, enabled, ignorecount),
-                self.condHistory, self, modal=True)
-            if dlg.exec_() == QDialog.Accepted:
-                cond, temp, enabled, ignorecount = dlg.getData()
-                self.breakpointModel.setBreakPointByIndex(
-                    index, self.fileName, ln,
-                    (cond, temp, enabled, ignorecount))
+                ln, cond, temp, enabled, ignorecount = self.breaks[handle]
+                index = self.breakpointModel.getBreakPointIndex(self.fileName,
+                                                                ln)
+                if not index.isValid():
+                    return
+                
+                from Debugger.EditBreakpointDialog import EditBreakpointDialog
+                dlg = EditBreakpointDialog(
+                    (self.fileName, ln),
+                    (cond, temp, enabled, ignorecount),
+                    self.condHistory, self, modal=True)
+                if dlg.exec_() == QDialog.Accepted:
+                    cond, temp, enabled, ignorecount = dlg.getData()
+                    self.breakpointModel.setBreakPointByIndex(
+                        index, self.fileName, ln,
+                        (cond, temp, enabled, ignorecount))
         
         self.line = -1
         
@@ -2413,7 +2407,7 @@
         @param fileName name of the file (string)
         """
         idxList = []
-        for handle, (ln, _, _, _, _) in list(self.breaks.items()):
+        for (ln, _, _, _, _) in self.breaks.values():
             index = self.breakpointModel.getBreakPointIndex(fileName, ln)
             if index.isValid():
                 idxList.append(index)
@@ -2771,7 +2765,7 @@
         newL = self.__lastSavedText.splitlines()
         matcher = difflib.SequenceMatcher(None, oldL, newL)
         
-        for token, i1, i2, j1, j2 in matcher.get_opcodes():
+        for token, _, _, j1, j2 in matcher.get_opcodes():
             if token in ["insert", "replace"]:
                 for lineNo in range(j1, j2):
                     self.markerAdd(lineNo, self.__changeMarkerSaved)
@@ -2782,7 +2776,7 @@
         newL = self.text().splitlines()
         matcher = difflib.SequenceMatcher(None, oldL, newL)
         
-        for token, i1, i2, j1, j2 in matcher.get_opcodes():
+        for token, _, _, j1, j2 in matcher.get_opcodes():
             if token in ["insert", "replace"]:
                 for lineNo in range(j1, j2):
                     self.markerAdd(lineNo, self.__changeMarkerUnsaved)
@@ -2804,7 +2798,7 @@
         newL = self.__lastSavedText.splitlines()
         matcher = difflib.SequenceMatcher(None, oldL, newL)
         
-        for token, i1, i2, j1, j2 in matcher.get_opcodes():
+        for token, _, _, j1, j2 in matcher.get_opcodes():
             if token in ["insert", "replace"]:
                 for lineNo in range(j1, j2):
                     self.markerAdd(lineNo, self.__changeMarkerSaved)
@@ -5698,7 +5692,7 @@
             self.toggleSyntaxError(lineno, col, True, msg)
         
         warnings = problems.get('warnings', [])
-        for _fn, lineno, col, code, msg in warnings:
+        for _fn, lineno, col, _code, msg in warnings:
             self.toggleWarning(lineno, col, True, msg)
         
         self.updateVerticalScrollBar()
--- a/QScintilla/EditorAssembly.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/QScintilla/EditorAssembly.py	Tue Mar 13 14:54:46 2018 +0100
@@ -316,23 +316,23 @@
         lineno += 1     # cursor position is zero based, code info one based
         
         # step 1: search in the globals
+        indexFound = 0
         for (lower, upper), index in self.__globalsBoundaries.items():
             if upper == -1:
                 upper = 1000000     # it is the last line
             if lower <= lineno <= upper:
+                indexFound = index
                 break
-        else:
-            index = 0
-        self.__globalsCombo.setCurrentIndex(index)
-        self.__globalsActivated(index, moveCursor=False)
+        self.__globalsCombo.setCurrentIndex(indexFound)
+        self.__globalsActivated(indexFound, moveCursor=False)
         
         # step 2: search in members
+        indexFound = 0
         for (lower, upper), index in self.__membersBoundaries.items():
             if upper == -1:
                 upper = 1000000     # it is the last line
             if lower <= lineno <= upper:
+                indexFound = index
                 break
-        else:
-            index = 0
-        self.__membersCombo.setCurrentIndex(index)
-        self.__membersActivated(index, moveCursor=False)
+        self.__membersCombo.setCurrentIndex(indexFound)
+        self.__membersActivated(indexFound, moveCursor=False)
--- a/QScintilla/QsciScintillaCompat.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/QScintilla/QsciScintillaCompat.py	Tue Mar 13 14:54:46 2018 +0100
@@ -1539,7 +1539,7 @@
             pos = self.SendScintilla(QsciScintilla.SCI_POSITIONFROMLINE, line)
             
             # Allow for multi-byte characters
-            for i in range(index):
+            for _ in range(index):
                 pos = self.positionAfter(pos)
             
             return pos
--- a/UI/NumbersWidget.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/UI/NumbersWidget.py	Tue Mar 13 14:54:46 2018 +0100
@@ -226,7 +226,7 @@
         # determine byte count
         byteCount = 8
         tmp = self.__input
-        for i in range(8):
+        for _ in range(8):
             c = (tmp & 0xff00000000000000) >> 7 * 8
             if c != 0 and self.__input >= 0:
                 break
@@ -301,7 +301,7 @@
         
         tmp1 = self.__input
         tmp2 = 0
-        for i in range(bytesIn):
+        for _ in range(bytesIn):
             tmp2 <<= 8
             tmp2 |= tmp1 & 0xff
             tmp1 >>= 8
--- a/UI/UserInterface.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/UI/UserInterface.py	Tue Mar 13 14:54:46 2018 +0100
@@ -3721,12 +3721,12 @@
         name = act.data()
         if name:
             if name == "__SHOW__":
-                for text, tb in list(self.__toolbars.values()):
+                for _text, tb in self.__toolbars.values():
                     tb.show()
                 if self.__menus["toolbars"].isTearOffMenuVisible():
                     self.__menus["toolbars"].hideTearOffMenu()
             elif name == "__HIDE__":
-                for text, tb in list(self.__toolbars.values()):
+                for _text, tb in self.__toolbars.values():
                     tb.hide()
                 if self.__menus["toolbars"].isTearOffMenuVisible():
                     self.__menus["toolbars"].hideTearOffMenu()
@@ -3747,10 +3747,10 @@
         name = act.data()
         if name:
             if name == "__SHOW__":
-                for text, tb in list(self.__toolbars.values()):
+                for _text, tb in self.__toolbars.values():
                     tb.show()
             elif name == "__HIDE__":
-                for text, tb in list(self.__toolbars.values()):
+                for _text, tb in self.__toolbars.values():
                     tb.hide()
             else:
                 tb = self.__toolbars[name][1]
@@ -4949,7 +4949,7 @@
         ioEncoding = Preferences.getSystem("IOEncoding")
         
         # loop through all running tool processes
-        for program, toolProc, toolProcData in self.toolProcs:
+        for program, toolProc, _toolProcData in self.toolProcs:
             toolProc.setReadChannel(QProcess.StandardError)
             
             while toolProc.canReadLine():
--- a/Utilities/BackgroundService.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Utilities/BackgroundService.py	Tue Mar 13 14:54:46 2018 +0100
@@ -445,6 +445,6 @@
             connection.blockSignals(True)
             connection.close()
         
-        for process, interpreter in self.processes.values():
+        for process, _interpreter in self.processes.values():
             process.close()
             process = None
--- a/Utilities/binplistlib.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Utilities/binplistlib.py	Tue Mar 13 14:54:46 2018 +0100
@@ -997,7 +997,7 @@
         all_positions = []
         writtenReferences = list(self.writtenReferences.items())
         writtenReferences.sort(key=lambda x: x[1])
-        for obj, order in writtenReferences:
+        for obj, _order in writtenReferences:
             position = self.referencePositions.get(obj)
             if position is None:
                 raise InvalidPlistException(
--- a/Utilities/crypto/py3AES.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Utilities/crypto/py3AES.py	Tue Mar 13 14:54:46 2018 +0100
@@ -289,7 +289,7 @@
         @return result (byte)
         """
         p = 0
-        for counter in range(8):
+        for _counter in range(8):
             if b & 1:
                 p ^= a
             hi_bit_set = a & 0x80
@@ -344,7 +344,7 @@
         @return modified state (bytearray)
         """
         state = state[:]
-        for i in range(nbr):
+        for _ in range(nbr):
             if isInv:
                 state[statePointer:statePointer + 4] = \
                     state[statePointer + 3:statePointer + 4] + \
--- a/Utilities/crypto/py3PBKDF2.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/Utilities/crypto/py3PBKDF2.py	Tue Mar 13 14:54:46 2018 +0100
@@ -37,7 +37,7 @@
     @return hashed password (bytes)
     """
     pwHash = password
-    for i in range(iterations):
+    for _ in range(iterations):
         pwHash = hmac.new(salt, pwHash, digestMod).digest()
     return pwHash
 
--- a/VCS/ProjectHelper.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/VCS/ProjectHelper.py	Tue Mar 13 14:54:46 2018 +0100
@@ -211,14 +211,17 @@
             0, False)
         if not ok:
             return
+        
+        selectedVcsSystem = None
         for vcsSystem, vcsSystemDisplay in list(vcsSystemsDict.items()):
             if vcsSystemDisplay == vcsSelected:
+                selectedVcsSystem = vcsSystem
                 break
         
         if not self.project.closeProject():
             return
         
-        vcs = self.project.initVCS(vcsSystem)
+        vcs = self.project.initVCS(selectedVcsSystem)
         if vcs is not None:
             vcsdlg = vcs.vcsNewProjectOptionsDialog()
             if vcsdlg.exec_() == QDialog.Accepted:
@@ -313,7 +316,7 @@
                             if dlg.exec_() == QDialog.Accepted:
                                 dlg.storeData()
                                 self.project.initFileTypes()
-                                self.project.pdata["VCS"] = vcsSystem
+                                self.project.pdata["VCS"] = selectedVcsSystem
                                 self.project.setDirty(True)
                                 if self.project.pdata["MAINSCRIPT"]:
                                     ms = os.path.join(
@@ -405,49 +408,54 @@
             0, False)
         if not ok:
             return
+        
+        selectedVcsSystem = None
         for vcsSystem, vcsSystemDisplay in list(vcsSystemsDict.items()):
             if vcsSystemDisplay == vcsSelected:
+                selectedVcsSystem = vcsSystem
                 break
         
-        self.project.pdata["VCS"] = vcsSystem
-        self.project.vcs = self.project.initVCS(vcsSystem)
-        if self.project.vcs is not None:
-            vcsdlg = self.project.vcs.vcsOptionsDialog(self.project,
-                                                       self.project.name, 1)
-            if vcsdlg.exec_() == QDialog.Accepted:
-                vcsDataDict = vcsdlg.getData()
-                # edit VCS command options
-                if self.project.vcs.vcsSupportCommandOptions():
-                    vcores = E5MessageBox.yesNo(
-                        self.parent(),
-                        QCoreApplication.translate(
-                            "VcsProjectHelper", "Import Project"),
-                        QCoreApplication.translate(
-                            "VcsProjectHelper",
-                            """Would you like to edit the VCS command"""
-                            """ options?"""))
+        if selectedVcsSystem is not None:
+            self.project.pdata["VCS"] = selectedVcsSystem
+            self.project.vcs = self.project.initVCS(selectedVcsSystem)
+            if self.project.vcs is not None:
+                vcsdlg = self.project.vcs.vcsOptionsDialog(
+                    self.project, self.project.name, 1)
+                if vcsdlg.exec_() == QDialog.Accepted:
+                    vcsDataDict = vcsdlg.getData()
+                    # edit VCS command options
+                    if self.project.vcs.vcsSupportCommandOptions():
+                        vcores = E5MessageBox.yesNo(
+                            self.parent(),
+                            QCoreApplication.translate(
+                                "VcsProjectHelper", "Import Project"),
+                            QCoreApplication.translate(
+                                "VcsProjectHelper",
+                                """Would you like to edit the VCS command"""
+                                """ options?"""))
+                    else:
+                        vcores = False
+                    if vcores:
+                        from .CommandOptionsDialog import \
+                            VcsCommandOptionsDialog
+                        codlg = VcsCommandOptionsDialog(self.project.vcs)
+                        if codlg.exec_() == QDialog.Accepted:
+                            self.project.vcs.vcsSetOptions(codlg.getOptions())
+                    self.project.setDirty(True)
+                    self.project.vcs.vcsSetDataFromDict(vcsDataDict)
+                    self.project.saveProject()
+                    isVcsControlled = self.project.vcs.vcsImport(
+                        vcsDataDict, self.project.ppath)[0]
+                    if isVcsControlled:
+                        # reopen the project
+                        self.project.openProject(self.project.pfile)
+                    else:
+                        # revert the changes to the local project
+                        # because the project dir is not a VCS directory
+                        revertChanges()
                 else:
-                    vcores = False
-                if vcores:
-                    from .CommandOptionsDialog import VcsCommandOptionsDialog
-                    codlg = VcsCommandOptionsDialog(self.project.vcs)
-                    if codlg.exec_() == QDialog.Accepted:
-                        self.project.vcs.vcsSetOptions(codlg.getOptions())
-                self.project.setDirty(True)
-                self.project.vcs.vcsSetDataFromDict(vcsDataDict)
-                self.project.saveProject()
-                isVcsControlled = self.project.vcs.vcsImport(
-                    vcsDataDict, self.project.ppath)[0]
-                if isVcsControlled:
-                    # reopen the project
-                    self.project.openProject(self.project.pfile)
-                else:
-                    # revert the changes to the local project
-                    # because the project dir is not a VCS directory
+                    # revert the changes because user cancelled
                     revertChanges()
-            else:
-                # revert the changes because user cancelled
-                revertChanges()
 
     def _vcsUpdate(self):
         """
--- a/VCS/__init__.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/VCS/__init__.py	Tue Mar 13 14:54:46 2018 +0100
@@ -40,23 +40,16 @@
     if vc is None:
         # try alternative vcs interfaces assuming, that there is a common
         # indicator for the alternatives
-        found = False
-        for indicator, vcsData in \
-                pluginManager.getVcsSystemIndicators().items():
-            for vcsSystem, vcsSystemDisplay in vcsData:
-                if vcsSystem == vcs:
-                    found = True
-                    break
-            
-            if found:
-                if len(vcsData) > 1:
-                    for vcsSystem, vcsSystemDisplay in vcsData:
+        for vcsData in pluginManager.getVcsSystemIndicators().values():
+            for vcsSystem, _vcsSystemDisplay in vcsData:
+                if vcsSystem == vcs and len(vcsData) > 1:
+                    for vcsSystem, _vcsSystemDisplay in vcsData:
                         if vcsSystem != vcs:
                             vc = pluginManager.getPluginObject(
                                 "version_control", vcsSystem, maybeActive=True)
                             if vc is not None:
-                                break
-                break
+                                return vc
+    
     return vc
 
 
--- a/uninstall-debugclients.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/uninstall-debugclients.py	Tue Mar 13 14:54:46 2018 +0100
@@ -112,7 +112,7 @@
     except getopt.GetoptError:
         usage()
 
-    for opt, arg in optlist:
+    for opt, _arg in optlist:
         if opt in ["-h", "--help"]:
             usage(0)
     
--- a/uninstall.py	Mon Mar 12 19:57:16 2018 +0100
+++ b/uninstall.py	Tue Mar 13 14:54:46 2018 +0100
@@ -342,7 +342,7 @@
 
     global platBinDir
 
-    for opt, arg in optlist:
+    for opt, _arg in optlist:
         if opt == "-h":
             usage(0)
         if opt == "-y":

eric ide

mercurial