2 Star 0 Fork 0

mirrors_gnu/solfege

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
mylint 1.59 KB
一键复制 编辑 原始数据 按行查看 历史
Tom Cato Amundsen 提交于 2013-03-29 01:55 . Initial commit
#!/usr/bin/python
# vim: set fileencoding=utf-8:
# Solfege - free ear training software
# Copyright (C) 2007 Tom Cato Amundsen
# License is GPL, see file COPYING
# I use this script with pylint version 0.12.1.
from __future__ import absolute_import
import codecs
import os
import shutil
import solfege.i18n
solfege.i18n.setup(".")
import sys
from pylint import lint
TMPDIR="mylint-tmpdir"
def tmpfilename(s):
p, fn = os.path.split(s)
return os.path.join(TMPDIR, p.replace("/", "-").replace("\\", "-")+"-"+fn)
def lint_file(fn):
tmpfn = tmpfilename(fn)
s = open(fn, 'rU').read()
outfile = open(tmpfn, 'w')
lines = s.split("\n")
# Try to find 4 comment lines in the beginning to drop.
i = 0
v = []
while True:
lines[i] = lines[i].lstrip(codecs.BOM_UTF8)
if not lines[i].startswith("#"):
break
if lines[i].startswith("# vim: set fileencoding"):
i += 1
continue
if lines[i].startswith("#"):
v.append(i)
i += 1
if len(v) == 4:
break
for i in reversed(v):
del lines[i]
for line in lines[:v[0]]:
print >> outfile, line
print >> outfile, "def _(s):\n return s"
print >> outfile, "def _i(s):\n return s"
outfile.write("\n".join(lines[v[0]:]))
outfile.close()
os.system('pylint --include-ids=y --disable=C0103 --good-names="i,j,k,ex,Run,_,s,m,i" --no-docstring-rgx=".*" %s' % tmpfn)
try:
os.mkdir(TMPDIR)
except OSError:
pass
for fn in sys.argv[1:]:
lint_file(fn)
try:
os.rmdir(TMPDIR)
except OSError:
pass
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_gnu/solfege.git
[email protected]:mirrors_gnu/solfege.git
mirrors_gnu
solfege
solfege
master

搜索帮助