分析记事本++的Python正确性(即lint)分析
,那么你可以通过下面的代码添加一个新的脚本变得相当好结果:
console.show()
console.clear()
console.run('cmd.exe /c '
+ 'C:\\Python26\\Scripts\\pylint.bat --reports=n -f parseable '
+ '"%s"' % notepad.getCurrentFilename())
输出将包含带有错误/警告的行的超链接(如果文件名中没有空格......)
你可以使用C:\Python34\Scripts>pip install pylint
安装pylint的,并通过记事本++的Run...
命令(F5)使用它:如果您安装了Python Script plugin
C:\Python34\Scripts\pylint.bat "$(FULL_CURRENT_PATH)"
你能更详细地解释一下? – jiamo 2014-04-24 03:25:12
选项“-f parseable”在当前版本的Pylint中已弃用。
当前等效替代是:
console.run('cmd.exe /c '
+ 'C:\\Python26\\Scripts\\pylint.bat --reports=n '
+ '--msg-template="%s" %s'
% ('{path}:{line}: {msg_id}({symbol}), {obj} {msg}', notepad.getCurrentFilename()))
注:蟒路径可以是不同的例如C:\\Python27.
注2:在--msg-template="..."
双引号是重要
没有其他的答案为我工作,但确实:使用C:\Python34\Scripts\pip.exe install pylint
通过安装NppExec
-
安装pylint的Plugin Manager,请按F6,并将此脚本另存为“PyLint 3.4”:
NPP_SAVE cd "$(FULL_CURRENT_PATH)" //env_set PYTHONIOENCODING=utf-16-le env_set PYTHONIOENCODING=utf-8 C:\Python34\Scripts\pylint.exe --reports=n -f parseable "$(FULL_CURRENT_PATH)"
输出示例:
Process started >>>
************* Module pylint2
pylint2.py:3: [C0330(bad-continuation), ] Wrong continued indentation (add 4 spaces).
+ 'C:\\Python26\\Scripts\\pylint.bat --reports=n '
^ |
pylint2.py:4: [C0330(bad-continuation), ] Wrong continued indentation (add 4 spaces).
+ '--msg-template="%s" %s'
^ |
pylint2.py:4: [C0303(trailing-whitespace), ] Trailing whitespace
pylint2.py:5: [C0330(bad-continuation), ] Wrong continued indentation (add 4 spaces).
% ('{path}:{line}: {msg_id}({symbol}), {obj} {msg}', notepad.getCurrentFilename()))
^ |
pylint2.py:5: [C0326(bad-whitespace), ] No space allowed after bracket
% ('{path}:{line}: {msg_id}({symbol}), {obj} {msg}', notepad.getCurrentFilename()))
^
pylint2.py:6: [C0304(missing-final-newline), ] Final newline missing
pylint2.py:1: [C0111(missing-docstring), ] Missing module docstring
pylint2.py:2: [E0602(undefined-variable), ] Undefined variable 'console'
pylint2.py:5: [E0602(undefined-variable), ] Undefined variable 'notepad'
No config file found, using default configuration
<<< Process finished. (Exit code 18)
您可以链接使用NppExec控制台输出筛选这些路径。按移 + F6并启用此过滤器,红色设置为FF
:
%FILE%:%LINE%:*
然后双击红线在编辑器中集中指定的位置。
如果您想在NotePad ++中使用Pylint,则应该使用可执行文件而不是批处理。
从Python脚本转到配置并创建一个新的.py文件以从中运行Pylint。 (我称为我的文件npphelper.py)
()将npphelper.py添加到菜单项和工具栏图标,然后可以通过按下按钮来执行它。)
这将运行pylint的到记事本++,我分裂命令分为两个部分:
pyLint = 'C:\\PROGRA~1\\Python35\\Scripts\\pylint.exe --reports=n'
console.show()
console.clear()
console.run('%s "%s"' % (pyLint, notepad.getCurrentFilename()))
- 路径pylint.exe(我用来代替双引号)
- 的一个短名称要检查Pylint的文件(actualy返回激活标签的路径)
(你必须改变的路径,使其适合于您的安装...)
所有你现在要做的是拯救这个npphelper.py,与你的项目文件打开Tab和运行您为pylint创建的npphelper.py。 (例如,通过按钮)
如果你不想使用默认的配置,然后生成一个pylintrc模板(保存他们要将)。我用下面的命令通过CMD做到了:
pylint.exe --generate-rcfile>>myfilename.pylintrc
然后,你需要改变一些线到npphelper.py:
rcfile = 'C:\\PROGRA~1\\Python35\\Scripts\\myrcfile.pylintrc'
pyLint = 'C:\\PROGRA~1\\Python35\\Scripts\\pylint.exe --reports=n --rcfile="%s"' % rcfile
console.show()
console.clear()
console.run('%s "%s"' % (pyLint, notepad.getCurrentFilename()))
我已经安装了Python脚本1.0。 8.0与所有其他使用.msi文件here。
(使用插件管理在记事本+ +为您提供了1.0.6.0版本,而不是1.0.8.0)
我使用的是Windows 7用记事本++ 6.9.1,3.5.1的Python和pylint的1.5.5。
(我通过CMD安装pylint的 - > “pip install pylint” 并更新其)
一些更多有用的链接:
由于从上面的链接到实际的下载是有点折磨,这里是一个直接的链接:http://sourceforge.net/projects/npppythonscript/files/ – thisismyrobot 2013-02-18 22:27:29