Py2 compatibility, pylint script based on project language.

Thu, 26 Sep 2013 22:53:14 +0200

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Thu, 26 Sep 2013 22:53:14 +0200
changeset 22
68beeb22dade
parent 21
f2144b9596a0
child 23
3c45744e2e3a

Py2 compatibility, pylint script based on project language.

ChangeLog file | annotate | diff | comparison | revisions
PluginPyLint.e4p file | annotate | diff | comparison | revisions
PluginPyLint.py file | annotate | diff | comparison | revisions
PluginPyLint.zip file | annotate | diff | comparison | revisions
PyLint/Documentation/source/Plugin_Checker_PyLint.PluginPyLint.html file | annotate | diff | comparison | revisions
PyLint/Documentation/source/Plugin_Checker_PyLint.PyLint.PyLintConfigDialog.html file | annotate | diff | comparison | revisions
PyLint/Documentation/source/Plugin_Checker_PyLint.PyLint.PyLintExecDialog.html file | annotate | diff | comparison | revisions
PyLint/Documentation/source/index-Plugin_Checker_PyLint.PyLint.html file | annotate | diff | comparison | revisions
PyLint/Documentation/source/index-Plugin_Checker_PyLint.html file | annotate | diff | comparison | revisions
PyLint/Documentation/source/index.html file | annotate | diff | comparison | revisions
PyLint/PyLintConfigDialog.py file | annotate | diff | comparison | revisions
PyLint/PyLintExecDialog.py file | annotate | diff | comparison | revisions
--- a/ChangeLog	Sun Apr 14 14:46:14 2013 +0200
+++ b/ChangeLog	Thu Sep 26 22:53:14 2013 +0200
@@ -1,5 +1,18 @@
 ChangeLog
 ---------
+Version 5.3.0:
+(compatible with Eric5.1.0 or greater)
+- bug fixes
+- STRING_FORMAT parameter for pylint 1.0.0 adapted
+- inverted checker selection
+- use the pylint version based on the project language
+- Python 2 compatibility for Eric 5
+- fixed an issue finding the executable in different registries 
+  on 64-bit Windows systems
+
+Version 5.2.1:
+- Changed usage of QMessageBox and QFileDialog to the eric5 equivalents
+
 Version 5.2.0:
 - bug fixes
 - modified code to do lazy import
--- a/PluginPyLint.e4p	Sun Apr 14 14:46:14 2013 +0200
+++ b/PluginPyLint.e4p	Thu Sep 26 22:53:14 2013 +0200
@@ -1,13 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE Project SYSTEM "Project-5.1.dtd">
 <!-- eric5 project file for project PluginPyLint -->
+<!-- Saved: 2013-09-26, 22:44:25 -->
+<!-- Copyright (C) 2013 Detlev Offenbach, detlev@die-offenbachs.de -->
 <Project version="5.1">
   <Language>en_US</Language>
   <Hash>abcf6641287ab95ca3df062cd9840dd92df2e42f</Hash>
   <ProgLanguage mixed="0">Python3</ProgLanguage>
   <ProjectType>E4Plugin</ProjectType>
   <Description>This plugin implements an eric5 interface to the pylint checker.</Description>
-  <Version>5.0.x</Version>
+  <Version>5.3.0</Version>
   <Author>Detlev Offenbach</Author>
   <Email>detlev@die-offenbachs.de</Email>
   <TranslationPattern>PyLint/i18n/pylint_%language%.ts</TranslationPattern>
@@ -160,7 +162,7 @@
               <string>cssFile</string>
             </key>
             <value>
-              <string>/usr/lib64/python2.7/site-packages/eric4/CSSs/default.css</string>
+              <string>%PYTHON%/eric5/CSSs/default.css</string>
             </value>
             <key>
               <string>ignoreDirectories</string>
--- a/PluginPyLint.py	Sun Apr 14 14:46:14 2013 +0200
+++ b/PluginPyLint.py	Thu Sep 26 22:53:14 2013 +0200
@@ -7,17 +7,31 @@
 Module implementing the PyLint plug-in.
 """
 
+from __future__ import unicode_literals    # __IGNORE_WARNING__
+try:
+    str = unicode
+except (NameError):
+    pass
+
+import re
 import os
-import sys
 import copy
+import platform
 
-from PyQt4.QtCore import QObject, QTranslator, QCoreApplication
+from PyQt4.QtCore import QObject, QTranslator, QCoreApplication, QProcess
 from PyQt4.QtGui import QDialog
 
-from E5Gui.E5Application import e5App
-from E5Gui.E5Action import E5Action
-from E5Gui import E5MessageBox
+try:
+    from E5Gui.E5Application import e5App
+    from E5Gui.E5Action import E5Action
+    from E5Gui import E5MessageBox
+    error = ""
+except ImportError:
+    error = QCoreApplication.translate("PyLintPlugin",
+        """Your version of Eric5 is not supported."""
+        """ At least version 5.1.0 of Eric5 is needed.""")
 
+import Preferences
 import Utilities
 
 # Start-of-Header
@@ -25,7 +39,7 @@
 author = "Detlev Offenbach <detlev@die-offenbachs.de>"
 autoactivate = True
 deactivateable = True
-version = "5.2.1"
+version = "5.3.0"
 className = "PyLintPlugin"
 packageName = "PyLint"
 shortDescription = "Show the PyLint dialogs."
@@ -35,16 +49,17 @@
 pyqtApi = 2
 # End-of-Header
 
-error = ""
+exePy2 = []
+exePy3 = []
 
-
-def exeDisplayData():
+def exeDisplayDataList():
     """
     Public method to support the display of some executable info.
     
     @return dictionary containing the data to query the presence of
         the executable
     """
+    dataList = []
     data = {
         "programEntry": True,
         "header": QCoreApplication.translate("PyLintPlugin",
@@ -56,69 +71,118 @@
         "version": "",
         "versionCleanup": (0, -1),
     }
-    exe = _findExecutable()
-    if exe:
-        data["exe"] = exe
-        data["versionStartsWith"] = 'pylint'
+    if _checkProgram():
+        for exePath in (exePy2[0], exePy3[0]):
+            data["exe"] = exePath
+            data["versionStartsWith"] = "pylint"
+            dataList.append(data.copy())
+    else:
+        dataList.append(data)
+    return dataList
+
+def __getProgramVersion(exe):
+    """
+    Private method to generate a program entry.
     
-    return data
+    @param exe name of the executable program (string)
+    @return version string of detected version (string)
+    """
+    proc = QProcess()
+    proc.setProcessChannelMode(QProcess.MergedChannels)
+    proc.start(exe, ['--version'])
+    finished = proc.waitForFinished(10000)
+    if finished:
+        output = str(proc.readAllStandardOutput(),
+                        Preferences.getSystem("IOEncoding"),
+                        'replace')
+        versionRe = re.compile('^pylint', re.UNICODE)
+        for line in output.splitlines():
+            if versionRe.search(line):
+                version = line.split()[-1]
+                version = version[:-1]
+                break
+        else:
+            version = '0.0.0'
+    return version
 
-
-def _findExecutable():
+def _findExecutable(majorVersion):
     """
     Restricted function to determine the name and path of the executable.
     
+    @param majorVersion major python version of the executables (int)
     @return path name of the executable (string)
     """
+    # Determine Python Version
+    if majorVersion == 3:
+        minorVersions = range(5)
+    elif majorVersion == 2:
+        minorVersions = range(5, 9)
+    else:
+        return []
+    
+    executables = set()
     if Utilities.isWindowsPlatform():
         #
         # Windows
         #
-        exe = 'pylint.bat'
-        if Utilities.isinpath(exe):
-            return exe
         try:
-            # only since python 3.2
-            import sysconfig
-            scripts = sysconfig.get_path('scripts', 'nt')
-            return os.path.join(scripts, exe)
+            import winreg
         except ImportError:
+            import _winreg as winreg    # __IGNORE_WARNING__
+        
+        def getExePath(branch, access, versionStr):
             try:
-                import winreg
-            except ImportError:
-                # give up ...
+                software = winreg.OpenKey(branch, 'Software', 0, access)
+                python = winreg.OpenKey(software, 'Python', 0, access)
+                pcore = winreg.OpenKey(python, 'PythonCore', 0, access)
+                version = winreg.OpenKey(pcore, versionStr, 0, access)
+                installpath = winreg.QueryValue(version, 'InstallPath')
+                exe = os.path.join(installpath, 'Scripts', 'pylint.bat')
+                if os.access(exe, os.X_OK):
+                    return exe
+            except WindowsError:        # __IGNORE_WARNING__
                 return None
+            return None
+        
+        for minorVersion in minorVersions:
+            versionStr = '{0}.{1}'.format(majorVersion, minorVersion)
+            exePath = getExePath(winreg.HKEY_CURRENT_USER,
+                winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr)
+                
+            if exePath is not None:
+                executables.add(exePath)
+            exePath = getExePath(winreg.HKEY_LOCAL_MACHINE,
+                winreg.KEY_WOW64_32KEY | winreg.KEY_READ, versionStr)
             
-            def getExePath(branch):
-                version = str(sys.version_info.major) + '.' + \
-                          str(sys.version_info.minor)
-                try:
-                    software = winreg.OpenKey(branch, 'Software')
-                    python = winreg.OpenKey(software, 'Python')
-                    pcore = winreg.OpenKey(python, 'PythonCore')
-                    version = winreg.OpenKey(pcore, version)
-                    installpath = winreg.QueryValue(version, 'InstallPath')
-                    return os.path.join(installpath, 'Scripts', exe)
-                except WindowsError:        # __IGNORE_WARNING__
-                    return None
-            
-            exePath = getExePath(winreg.HKEY_CURRENT_USER)
-            if not exePath:
-                exePath = getExePath(winreg.HKEY_LOCAL_MACHINE)
-            return exePath
+            # Even on Intel 64-bit machines it's 'AMD64'
+            if platform.machine() == 'AMD64':
+                if exePath is not None:
+                    executables.add(exePath)
+                exePath = getExePath(winreg.HKEY_CURRENT_USER,
+                    winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr)
+                
+                if exePath is not None:
+                    executables.add(exePath)
+                exePath = getExePath(winreg.HKEY_LOCAL_MACHINE,
+                    winreg.KEY_WOW64_64KEY | winreg.KEY_READ, versionStr)
+                
+                if exePath is not None:
+                    executables.add(exePath)
     else:
         #
         # Linux, Unix ...
         pylintScript = 'pylint'
         scriptSuffixes = ["",
-                          "-python{0}".format(sys.version[:1]),
-                          "-python{0}".format(sys.version[:3])]
+                    "-python{0}".format(majorVersion)]
+        for minorVersion in minorVersions:
+            scriptSuffixes.append(
+                    "-python{0}.{1}".format(majorVersion, minorVersion))
         # There could be multiple pylint executables in the path
         # e.g. for different python variants
         path = Utilities.getEnvironmentEntry('PATH')
         # environment variable not defined
         if path is None:
-            return None
+            return []
         
         # step 1: determine possible candidates
         exes = []
@@ -129,25 +193,40 @@
                 if os.access(exe, os.X_OK):
                     exes.append(exe)
         
-        # step 2: determine the Python 3 variant
-        found = False
+        # step 2: determine the Python variant
         if Utilities.isMacPlatform():
-            checkStr = "Python.framework/Versions/3".lower()
+            checkStrings = ["Python.framework/Versions/3".lower(),
+                            "python3"]
         else:
-            checkStr = "python3"
+            checkStrings = ["python3"]
+        
+        _exePy2 = set()
+        _exePy3 = set()
         for exe in exes:
             try:
                 f = open(exe, "r")
                 line0 = f.readline()
-                if checkStr in line0.lower():
-                    found = True
+                for checkStr in checkStrings:
+                    if checkStr in line0.lower():
+                        _exePy3.add(exe)
+                        break
+                else:
+                    _exePy2.add(exe)
             finally:
                 f.close()
-            if found:
-                return exe
+        
+        executables = _exePy3 if majorVersion == 3 else _exePy2
     
-    return None
+    # Find the executable with the highest version number
+    maxVersion = '0.0.0'
+    maxExe = ''
+    for executable in list(executables):
+        version = __getProgramVersion(executable)
+        if version > maxVersion:
+            maxVersion = version
+            maxExe = executable
 
+    return maxExe, maxVersion
 
 def _checkProgram():
     """
@@ -155,12 +234,18 @@
     
     @return flag indicating availability (boolean)
     """
-    global error
+    global error, exePy2, exePy3
     
-    if _findExecutable() is None:
+    exePy2 = _findExecutable(2)
+    exePy3 = _findExecutable(3)
+    if exePy2[0] == '' and exePy3[0] == '':
         error = QCoreApplication.translate("PyLintPlugin",
             "The pylint executable could not be found.")
         return False
+    elif exePy2[1] < '0.23.0' and exePy3[1] < '0.23.0':
+        error = QCoreApplication.translate("PyLintPlugin",
+            "PyLint version < 0.23.0.")
+        return False
     else:
         return True
 
@@ -208,19 +293,13 @@
         """
         global error
         
+        # There is already an error, don't activate
+        if error:
+            return None, False
         # pylint is only activated if it is available
         if not _checkProgram():
             return None, False
         
-        try:
-            from pylint.__pkginfo__ import numversion
-            if numversion < (0, 23, 0):
-                error = self.trUtf8("PyLint version < 0.23.0.")
-                return None, False
-        except ImportError:
-            error = self.trUtf8("Cannot determine pylint version.")
-            return None, False
-        
         menu = e5App().getObject("Project").getMenu("Checks")
         if menu:
             self.__projectAct = E5Action(self.trUtf8('Run PyLint'),
@@ -333,12 +412,11 @@
         @param menu reference to the menu (QMenu)
         """
         if menuName == "Checks":
+            lang = e5App().getObject("Project").getProjectLanguage()
             if self.__projectAct is not None:
-                self.__projectAct.setEnabled(
-                    e5App().getObject("Project").getProjectLanguage() == "Python3")
+                self.__projectAct.setEnabled(lang.startswith("Python"))
             if self.__projectShowAct is not None:
-                self.__projectShowAct.setEnabled(
-                    e5App().getObject("Project").getProjectLanguage() == "Python3")
+                self.__projectShowAct.setEnabled(lang.startswith("Python"))
             self.__projectShowAct.setEnabled(self.__pylintPDialog is not None)
     
     def __projectBrowserShowMenu(self, menuName, menu):
@@ -350,7 +428,7 @@
         @param menu reference to the menu (QMenu)
         """
         if menuName == "Checks" and \
-           e5App().getObject("Project").getProjectLanguage() == "Python3":
+           e5App().getObject("Project").getProjectLanguage().startswith("Python"):
             self.__projectBrowserMenu = menu
             if self.__projectBrowserAct is None:
                 self.__projectBrowserAct = E5Action(self.trUtf8('Run PyLint'),
@@ -393,17 +471,26 @@
         """
         if forEditor:
             parms = copy.deepcopy(self.__editorParms)
+            editor = e5App().getObject("ViewManager").getOpenEditor(mpName)
+            majorVersionStr = editor.getLanguage()
         else:
             parms = project.getData('CHECKERSPARMS', "PYLINT")
-        exe = _findExecutable()
-        if exe is None:
+            majorVersionStr = project.getProjectLanguage()
+        exe, version = {"Python": exePy2, "Python2": exePy2,
+                              "Python3": exePy3}.get(majorVersionStr)
+        if exe == '':
             E5MessageBox.critical(None,
                 self.trUtf8("pylint"),
                 self.trUtf8("""The pylint executable could not be found."""))
             return
+        elif version < '0.23.0':
+            E5MessageBox.critical(None,
+                self.trUtf8("pylint"),
+                self.trUtf8("PyLint version < 0.23.0."))
+            return
         
         from PyLint.PyLintConfigDialog import PyLintConfigDialog
-        dlg = PyLintConfigDialog(project.getProjectPath(), exe, parms)
+        dlg = PyLintConfigDialog(project.getProjectPath(), exe, parms, version)
         if dlg.exec_() == QDialog.Accepted:
             args, parms = dlg.generateParameters()
             self.__editorParms = copy.deepcopy(parms)
@@ -413,10 +500,7 @@
             # now do the call
             from PyLint.PyLintExecDialog import PyLintExecDialog
             dlg2 = PyLintExecDialog()
-            try:
-                reportFile = parms['reportFile']
-            except KeyError:
-                reportFile = None
+            reportFile = parms.get('reportFile', None)
             res = dlg2.start(args, mpName, reportFile, project.getProjectPath())
             if res:
                 dlg2.show()
@@ -498,7 +582,7 @@
         if menuName == "Checks":
             if not self.__editorAct in menu.actions():
                 menu.addAction(self.__editorAct)
-            self.__editorAct.setEnabled(editor.isPy3File())
+            self.__editorAct.setEnabled(editor.isPy3File() or editor.isPy2File())
     
     def __editorPylint(self):
         """
Binary file PluginPyLint.zip has changed
--- a/PyLint/Documentation/source/Plugin_Checker_PyLint.PluginPyLint.html	Sun Apr 14 14:46:14 2013 +0200
+++ b/PyLint/Documentation/source/Plugin_Checker_PyLint.PluginPyLint.html	Thu Sep 26 22:53:14 2013 +0200
@@ -4,17 +4,17 @@
 <meta charset="UTF-8">
 <style>
 body {
-    background:white;
+    background: #EDECE6;
     margin: 0em 1em 10em 1em;
     color: black;
 }
 
-h1 { color: white; background: #4FA4FF; }
-h2 { color: white; background: #4FA4FF; }
-h3 { color: white; background: #00557F; }
-h4 { color: white; background: #00557F; }
+h1 { color: white; background: #85774A; }
+h2 { color: white; background: #85774A; }
+h3 { color: white; background: #9D936E; }
+h4 { color: white; background: #9D936E; }
     
-a { color: #AA5500; }
+a { color: #BA6D36; }
 
 </style>
 </head>
@@ -25,7 +25,7 @@
 </p>
 <h3>Global Attributes</h3>
 <table>
-<tr><td>author</td></tr><tr><td>autoactivate</td></tr><tr><td>className</td></tr><tr><td>deactivateable</td></tr><tr><td>error</td></tr><tr><td>longDescription</td></tr><tr><td>name</td></tr><tr><td>needsRestart</td></tr><tr><td>packageName</td></tr><tr><td>pyqtApi</td></tr><tr><td>shortDescription</td></tr><tr><td>version</td></tr>
+<tr><td>author</td></tr><tr><td>autoactivate</td></tr><tr><td>className</td></tr><tr><td>deactivateable</td></tr><tr><td>exePy2</td></tr><tr><td>exePy3</td></tr><tr><td>longDescription</td></tr><tr><td>name</td></tr><tr><td>needsRestart</td></tr><tr><td>packageName</td></tr><tr><td>pyqtApi</td></tr><tr><td>shortDescription</td></tr><tr><td>version</td></tr>
 </table>
 <h3>Classes</h3>
 <table>
@@ -37,13 +37,16 @@
 <h3>Functions</h3>
 <table>
 <tr>
+<td><a href="#__getProgramVersion">__getProgramVersion</a></td>
+<td>Private method to generate a program entry.</td>
+</tr><tr>
 <td><a href="#_checkProgram">_checkProgram</a></td>
 <td>Restricted function to check the availability of pylint.</td>
 </tr><tr>
 <td><a href="#_findExecutable">_findExecutable</a></td>
 <td>Restricted function to determine the name and path of the executable.</td>
 </tr><tr>
-<td><a href="#exeDisplayData">exeDisplayData</a></td>
+<td><a href="#exeDisplayDataList">exeDisplayDataList</a></td>
 <td>Public method to support the display of some executable info.</td>
 </tr><tr>
 <td><a href="#getExePath">getExePath</a></td>
@@ -267,6 +270,24 @@
 </p>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
+<a NAME="__getProgramVersion" ID="__getProgramVersion"></a>
+<h2>__getProgramVersion</h2>
+<b>__getProgramVersion</b>(<i>exe</i>)
+<p>
+    Private method to generate a program entry.
+</p><dl>
+<dt><i>exe</i></dt>
+<dd>
+name of the executable program (string)
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+version string of detected version (string)
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr /><hr />
 <a NAME="_checkProgram" ID="_checkProgram"></a>
 <h2>_checkProgram</h2>
 <b>_checkProgram</b>(<i></i>)
@@ -282,10 +303,15 @@
 <hr /><hr />
 <a NAME="_findExecutable" ID="_findExecutable"></a>
 <h2>_findExecutable</h2>
-<b>_findExecutable</b>(<i></i>)
+<b>_findExecutable</b>(<i>majorVersion</i>)
 <p>
     Restricted function to determine the name and path of the executable.
 </p><dl>
+<dt><i>majorVersion</i></dt>
+<dd>
+major python version of the executables (int)
+</dd>
+</dl><dl>
 <dt>Returns:</dt>
 <dd>
 path name of the executable (string)
@@ -293,9 +319,9 @@
 </dl>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
-<a NAME="exeDisplayData" ID="exeDisplayData"></a>
-<h2>exeDisplayData</h2>
-<b>exeDisplayData</b>(<i></i>)
+<a NAME="exeDisplayDataList" ID="exeDisplayDataList"></a>
+<h2>exeDisplayDataList</h2>
+<b>exeDisplayDataList</b>(<i></i>)
 <p>
     Public method to support the display of some executable info.
 </p><dl>
@@ -309,7 +335,7 @@
 <hr /><hr />
 <a NAME="getExePath" ID="getExePath"></a>
 <h2>getExePath</h2>
-<b>getExePath</b>(<i>branch</i>)
+<b>getExePath</b>(<i>branch, access, versionStr</i>)
 
 <div align="right"><a href="#top">Up</a></div>
 <hr />
--- a/PyLint/Documentation/source/Plugin_Checker_PyLint.PyLint.PyLintConfigDialog.html	Sun Apr 14 14:46:14 2013 +0200
+++ b/PyLint/Documentation/source/Plugin_Checker_PyLint.PyLint.PyLintConfigDialog.html	Thu Sep 26 22:53:14 2013 +0200
@@ -4,17 +4,17 @@
 <meta charset="UTF-8">
 <style>
 body {
-    background:white;
+    background: #EDECE6;
     margin: 0em 1em 10em 1em;
     color: black;
 }
 
-h1 { color: white; background: #4FA4FF; }
-h2 { color: white; background: #4FA4FF; }
-h3 { color: white; background: #00557F; }
-h4 { color: white; background: #00557F; }
+h1 { color: white; background: #85774A; }
+h2 { color: white; background: #85774A; }
+h3 { color: white; background: #9D936E; }
+h4 { color: white; background: #9D936E; }
     
-a { color: #AA5500; }
+a { color: #BA6D36; }
 
 </style>
 </head>
@@ -94,7 +94,7 @@
 </table>
 <a NAME="PyLintConfigDialog.__init__" ID="PyLintConfigDialog.__init__"></a>
 <h4>PyLintConfigDialog (Constructor)</h4>
-<b>PyLintConfigDialog</b>(<i>ppath, exe, parms=None, parent=None</i>)
+<b>PyLintConfigDialog</b>(<i>ppath, exe, parms, version</i>)
 <p>
         Constructor
 </p><dl>
@@ -108,9 +108,9 @@
 </dd><dt><i>parms</i></dt>
 <dd>
 parameters to set in the dialog
-</dd><dt><i>parent</i></dt>
+</dd><dt><i>version</i></dt>
 <dd>
-reference to the parent widget (QWidget)
+pylint version (string)
 </dd>
 </dl><a NAME="PyLintConfigDialog.__createConfigDone" ID="PyLintConfigDialog.__createConfigDone"></a>
 <h4>PyLintConfigDialog.__createConfigDone</h4>
--- a/PyLint/Documentation/source/Plugin_Checker_PyLint.PyLint.PyLintExecDialog.html	Sun Apr 14 14:46:14 2013 +0200
+++ b/PyLint/Documentation/source/Plugin_Checker_PyLint.PyLint.PyLintExecDialog.html	Thu Sep 26 22:53:14 2013 +0200
@@ -4,17 +4,17 @@
 <meta charset="UTF-8">
 <style>
 body {
-    background:white;
+    background: #EDECE6;
     margin: 0em 1em 10em 1em;
     color: black;
 }
 
-h1 { color: white; background: #4FA4FF; }
-h2 { color: white; background: #4FA4FF; }
-h3 { color: white; background: #00557F; }
-h4 { color: white; background: #00557F; }
+h1 { color: white; background: #85774A; }
+h2 { color: white; background: #85774A; }
+h3 { color: white; background: #9D936E; }
+h4 { color: white; background: #9D936E; }
     
-a { color: #AA5500; }
+a { color: #BA6D36; }
 
 </style>
 </head>
--- a/PyLint/Documentation/source/index-Plugin_Checker_PyLint.PyLint.html	Sun Apr 14 14:46:14 2013 +0200
+++ b/PyLint/Documentation/source/index-Plugin_Checker_PyLint.PyLint.html	Thu Sep 26 22:53:14 2013 +0200
@@ -4,17 +4,17 @@
 <meta charset="UTF-8">
 <style>
 body {
-    background:white;
+    background: #EDECE6;
     margin: 0em 1em 10em 1em;
     color: black;
 }
 
-h1 { color: white; background: #4FA4FF; }
-h2 { color: white; background: #4FA4FF; }
-h3 { color: white; background: #00557F; }
-h4 { color: white; background: #00557F; }
+h1 { color: white; background: #85774A; }
+h2 { color: white; background: #85774A; }
+h3 { color: white; background: #9D936E; }
+h4 { color: white; background: #9D936E; }
     
-a { color: #AA5500; }
+a { color: #BA6D36; }
 
 </style>
 </head>
--- a/PyLint/Documentation/source/index-Plugin_Checker_PyLint.html	Sun Apr 14 14:46:14 2013 +0200
+++ b/PyLint/Documentation/source/index-Plugin_Checker_PyLint.html	Thu Sep 26 22:53:14 2013 +0200
@@ -4,17 +4,17 @@
 <meta charset="UTF-8">
 <style>
 body {
-    background:white;
+    background: #EDECE6;
     margin: 0em 1em 10em 1em;
     color: black;
 }
 
-h1 { color: white; background: #4FA4FF; }
-h2 { color: white; background: #4FA4FF; }
-h3 { color: white; background: #00557F; }
-h4 { color: white; background: #00557F; }
+h1 { color: white; background: #85774A; }
+h2 { color: white; background: #85774A; }
+h3 { color: white; background: #9D936E; }
+h4 { color: white; background: #9D936E; }
     
-a { color: #AA5500; }
+a { color: #BA6D36; }
 
 </style>
 </head>
--- a/PyLint/Documentation/source/index.html	Sun Apr 14 14:46:14 2013 +0200
+++ b/PyLint/Documentation/source/index.html	Thu Sep 26 22:53:14 2013 +0200
@@ -4,17 +4,17 @@
 <meta charset="UTF-8">
 <style>
 body {
-    background:white;
+    background: #EDECE6;
     margin: 0em 1em 10em 1em;
     color: black;
 }
 
-h1 { color: white; background: #4FA4FF; }
-h2 { color: white; background: #4FA4FF; }
-h3 { color: white; background: #00557F; }
-h4 { color: white; background: #00557F; }
+h1 { color: white; background: #85774A; }
+h2 { color: white; background: #85774A; }
+h3 { color: white; background: #9D936E; }
+h4 { color: white; background: #9D936E; }
     
-a { color: #AA5500; }
+a { color: #BA6D36; }
 
 </style>
 </head>
--- a/PyLint/PyLintConfigDialog.py	Sun Apr 14 14:46:14 2013 +0200
+++ b/PyLint/PyLintConfigDialog.py	Thu Sep 26 22:53:14 2013 +0200
@@ -7,6 +7,12 @@
 Module implementing a dialog to configure the PyLint process
 """
 
+from __future__ import unicode_literals    # __IGNORE_WARNING__
+try:
+    str = unicode
+except (NameError):
+    pass
+
 import os
 import copy
 
@@ -27,7 +33,7 @@
     """
     Class implementing a dialog to configure the PyLint process
     """
-    def __init__(self, ppath, exe, parms=None, parent=None):
+    def __init__(self, ppath, exe, parms, version):
         """
         Constructor
         
@@ -35,11 +41,12 @@
             Used to set the default path for the rcfile selection dialog
         @param exe name of the pylint executable (string)
         @param parms parameters to set in the dialog
-        @param parent reference to the parent widget (QWidget)
+        @param version pylint version (string)
         """
-        super().__init__(parent)
+        super(PyLintConfigDialog, self).__init__(None)
         self.setupUi(self)
         
+        self.version = version
         self.pylintProc = None
         self.lint = exe
         
@@ -101,20 +108,20 @@
             'dialogReport': False,
             
             # enabled checkers
-            'enableBasic': False,
-            'enableClasses': False,
-            'enableDesign': False,
-            'enableExceptions': False,
+            'enableBasic': True,
+            'enableClasses': True,
+            'enableDesign': True,
+            'enableExceptions': True,
             'enableFormat': False,
             'enableImports': False,
+            'enableLogging': True,
             'enableMetrics': True,
-            'enableMiscellaneous': False,
-            'enableNewstyle': False,
-            'enableSimilarities': False,
-            'enableTypecheck': False,
-            'enableVariables': False,
-            'enableLogging': False,
-            'enableStringFormat': False,
+            'enableMiscellaneous': True,
+            'enableNewstyle': True,
+            'enableSimilarities': True,
+            'enableStringFormat': True,
+            'enableTypecheck': True,
+            'enableVariables': True,
             
             # messages
             'enabledMessages': '',
@@ -205,7 +212,12 @@
         if self.parameters['enableLogging']:
             checkers.append('logging')
         if self.parameters['enableStringFormat']:
-            checkers.append('string_format')
+            if self.version > '0.27.0':
+                checkers.append('string')
+            else:
+                checkers.append('string_format')
+            
+        args.append('--disable=all')
         if checkers:
             args.append('--enable={0}'.format(','.join(checkers)))
         
@@ -291,7 +303,7 @@
             [m.strip() for m in self.disabledMessagesEdit.text().split(',')])
         
         # call the accept slot of the base class
-        super().accept()
+        super(PyLintConfigDialog, self).accept()
 
     ############################################################################
     ## Methods below are needed to generate a configuration file template
--- a/PyLint/PyLintExecDialog.py	Sun Apr 14 14:46:14 2013 +0200
+++ b/PyLint/PyLintExecDialog.py	Thu Sep 26 22:53:14 2013 +0200
@@ -7,6 +7,12 @@
 Module implementing a dialog to show the results of the PyLint run.
 """
 
+from __future__ import unicode_literals    # __IGNORE_WARNING__
+try:
+    str = unicode
+except (NameError):
+    pass
+
 import os
 
 from PyQt4.QtCore import QTimer, QProcess, Qt, pyqtSlot
@@ -361,8 +367,10 @@
                 return
         
         try:
-            f = open(self.reportFile, 'w')
-            f.write(self.buf)
+            import codecs
+            f = open(self.reportFile, 'wb')
+            f.write(codecs.BOM_UTF8)
+            f.write(self.buf.encode('utf-8'))
             f.close()
         except IOError as why:
             E5MessageBox.critical(self, self.trUtf8('PyLint Report'),
@@ -385,7 +393,6 @@
             self.trUtf8("PyLint Report"),
             self.ppath,
             filter,
-            None,
             E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite))
         if self.reportFile:
             self.__writeReport()

eric ide

mercurial