本文整理汇总了Python中pyflakes.scripts.pyflakes.checkPath函数的典型用法代码示例。如果您正苦于以下问题:Python checkPath函数的具体用法?Python checkPath怎么用?Python checkPath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkPath函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _run_pyflakes_analysis
def _run_pyflakes_analysis(self, package):
package_path = os.path.dirname(package.__file__)
for dir_path, dir_names, file_names in os.walk(package_path):
for file_name in file_names:
if file_name.endswith('.py'):
file_path = os.path.join(dir_path, file_name)
checkPath(file_path)
开发者ID:miing,项目名称:mci_migo_packages_u1-test-utils,代码行数:7,代码来源:test_pyflakes_analysis.py
示例2: run
def run(self, apps_locations, **options):
output = open(os.path.join(options['output_dir'], 'pyflakes.report'), 'w')
# run pyflakes tool with captured output
old_stdout, pyflakes_output = sys.stdout, StringIO()
sys.stdout = pyflakes_output
try:
for location in apps_locations:
if os.path.isdir(location):
for dirpath, dirnames, filenames in os.walk(os.path.relpath(location)):
if dirpath.endswith(tuple(
''.join([os.sep, exclude_dir]) for exclude_dir in options['pyflakes_exclude_dirs'])):
continue
for filename in filenames:
if filename.endswith('.py'):
pyflakes.checkPath(os.path.join(dirpath, filename))
else:
pyflakes.checkPath(os.path.relpath(location))
finally:
sys.stdout = old_stdout
# save report
pyflakes_output.seek(0)
while True:
line = pyflakes_output.readline()
if not line:
break
message = re.sub(r': ', r': [E] PYFLAKES:', line)
output.write(message)
output.close()
开发者ID:PCreations,项目名称:django-jenkins,代码行数:33,代码来源:run_pyflakes.py
示例3: teardown_test_environment
def teardown_test_environment(self, **kwargs):
locations = get_apps_locations(self.test_labels, self.test_all)
# run pyflakes tool with captured output
old_stdout, pyflakes_output = sys.stdout, StringIO()
sys.stdout = pyflakes_output
try:
for location in locations:
if os.path.isdir(location):
for dirpath, dirnames, filenames in os.walk(relpath(location)):
for filename in filenames:
if filename.endswith('.py'):
pyflakes.checkPath(os.path.join(dirpath, filename))
else:
pyflakes.checkPath(relpath(location))
finally:
sys.stdout = old_stdout
# save report
pyflakes_output.reset()
while True:
line = pyflakes_output.readline()
if not line:
break
message = re.sub(r': ', r': [E] PYFLAKES:', line)
self.output.write(message)
self.output.close()
开发者ID:Atala,项目名称:META-SHARE,代码行数:28,代码来源:run_pyflakes.py
示例4: directory_py_files
def directory_py_files(self, parent_directory):
import pyflakes.scripts.pyflakes as pyflake
directory_generator = os.walk(parent_directory)
directory_info = directory_generator.next()
for file in directory_info[2]:
if file.endswith('py') and not file.startswith('__init__'):
pyflake.checkPath('%s/%s' % (directory_info[0], file))
for directory in directory_info[1]:
if not directory.startswith('.') and not directory.startswith('migrations'):
self.directory_py_files('%s/%s' % (parent_directory, directory))
开发者ID:openstate,项目名称:Wiekiesjij,代码行数:10,代码来源:flake_check.py
示例5: __check_path
def __check_path(self, path):
old_stdout = sys.stdout
stream = FakeStream()
try:
sys.stdout = stream
for dirpath, dirnames, filenames in os.walk(path):
for filename in filenames:
if filename.endswith('.py'):
pyflakes.checkPath(os.path.join(dirpath, filename))
finally:
sys.stdout = old_stdout
stream.check()
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:12,代码来源:test_pyflakes.py
示例6: test_pyflakes
def test_pyflakes(self):
"""Check all the code."""
stdout = StringIO()
with patch('sys.stdout', stdout):
for dirpath, _, filenames in os.walk('src'):
for filename in filenames:
if filename.endswith('.py'):
checkPath(os.path.join(dirpath, filename))
errors = [line.strip() for line in stdout.getvalue().splitlines()
if line.strip()]
if errors:
self.fail('\n'.join(errors))
开发者ID:CSRedRat,项目名称:magicicada-gui,代码行数:13,代码来源:test_code_style.py
示例7: _run
def _run(self, path, **kwargs):
old_stdout = sys.stdout
stream = FakeStream(**kwargs)
try:
sys.stdout = stream
for dirpath, dirnames, filenames in os.walk(path):
for filename in filenames:
if _compat.PY3 and filename in ("m4a.py", "test_m4a.py"):
continue
if filename.endswith('.py'):
pyflakes.checkPath(os.path.join(dirpath, filename))
finally:
sys.stdout = old_stdout
stream.check()
开发者ID:Shutshutnunte,项目名称:mutagen,代码行数:14,代码来源:test_pyflakes.py
示例8: _run
def _run(self, path):
old_stdout = sys.stdout
stream = StringIO()
try:
sys.stdout = stream
for dirpath, dirnames, filenames in os.walk(path):
for filename in filenames:
if filename.endswith('.py'):
pyflakes.checkPath(os.path.join(dirpath, filename))
finally:
sys.stdout = old_stdout
lines = stream.getvalue()
if lines:
raise Exception(lines)
开发者ID:quodlibet,项目名称:mutagen,代码行数:14,代码来源:test_pyflakes.py
示例9: __check_path
def __check_path(self, path):
if not pyflakes:
raise Exception("pyflakes missing; please install")
old_stdout = sys.stdout
stream = FakeStream()
try:
sys.stdout = stream
for dirpath, dirnames, filenames in os.walk(path):
for filename in filenames:
if filename.endswith('.py'):
pyflakes.checkPath(os.path.join(dirpath, filename))
finally:
sys.stdout = old_stdout
stream.check()
开发者ID:bp0,项目名称:quodlibet,代码行数:15,代码来源:test_pyflakes.py
示例10: audit
def audit():
"""Audit WxGeometrie's source with PyFlakes.
Audit WxGeometrie source code for following issues:
- Names which are used but not defined or used before they are defined.
- Names which are redefined without having been used.
"""
os.chdir(WXGEODIR)
try:
import pyflakes.scripts.pyflakes as flakes
except ImportError:
print("""In order to run the audit, you need to have PyFlakes installed.""")
sys.exit(-1)
print('\n == Auditing files... ==')
warns = 0
for dirpath, dirnames, filenames in os.walk('.'):
if not any((dirpath.startswith('./' + dir) or dir + '/' == dirpath) for dir in SKIP_DIRS):
print('\nAuditing ' + dirpath + '...')
print([('./' + dir, dirpath.startswith('./' + dir)) for dir in SKIP_DIRS])
for filename in filenames:
if filename.endswith('.py') and filename != '__init__.py':
warns += flakes.checkPath(os.path.join(dirpath, filename))
if warns > 0:
print("Audit finished with total %d warnings" % warns)
else:
print("Audit finished without any warning. :)")
开发者ID:wxgeo,项目名称:ptyx,代码行数:26,代码来源:test.py
示例11: check_pyflakes
def check_pyflakes(srcdir):
print(">>> Running pyflakes...")
clean = True
for pyfile in findpy(srcdir):
if pyflakes.checkPath(pyfile) != 0:
clean = False
return clean
开发者ID:agua,项目名称:StarCluster,代码行数:7,代码来源:check.py
示例12: run
def run(self):
import sys
try:
import pyflakes.scripts.pyflakes as flakes
except ImportError:
print "Audit requires PyFlakes installed in your system."
sys.exit(-1)
warns = 0
# Define top-level directories
dirs = ('.')
for dir in dirs:
for root, _, files in os.walk(dir):
if root.startswith(('./build', './doc')):
continue
for file in files:
if not file.endswith(('__init__.py', 'upload.py')) \
and file.endswith('.py'):
warns += flakes.checkPath(os.path.join(root, file))
if warns > 0:
print "Audit finished with total %d warnings." % warns
sys.exit(-1)
else:
print "No problems found in sourcecode."
sys.exit(0)
开发者ID:aroraumang,项目名称:trytond-avalara,代码行数:25,代码来源:setup.py
示例13: test_missingTrailingNewline
def test_missingTrailingNewline(self):
"""
Source which doesn't end with a newline shouldn't cause any
exception to be raised nor an error indicator to be returned by
L{check}.
"""
fName = fileWithContents("def foo():\n\tpass\n\t")
self.assertFalse(checkPath(fName))
开发者ID:ImadBouirmane,项目名称:spyder,代码行数:8,代码来源:test_script.py
示例14: test_checkPathNonExisting
def test_checkPathNonExisting(self):
"""
L{checkPath} handles non-existing files.
"""
err = StringIO()
count = withStderrTo(err, lambda: checkPath('extremo'))
self.assertEquals(err.getvalue(), 'extremo: No such file or directory\n')
self.assertEquals(count, 1)
开发者ID:ImadBouirmane,项目名称:spyder,代码行数:8,代码来源:test_script.py
示例15: output
def output(self):
stderr, sys.stderr = sys.stderr, StringIO.StringIO()
stdout, sys.stdout = sys.stdout, StringIO.StringIO()
try:
from pyflakes.scripts import pyflakes
pyflakes.checkPath(self.path)
errors = sys.stderr.getvalue().strip()
if errors:
return errors
else:
output = sys.stdout.getvalue().strip()
return output
finally:
sys.stderr = stderr
sys.stdout = stdout
开发者ID:tclancy,项目名称:perfectpython,代码行数:19,代码来源:checkers.py
示例16: Pyflakes
def Pyflakes(path, modules):
try:
from pyflakes.scripts.pyflakes import checkPath
except ImportError:
print("PYFLAKES not installed. Skipping.")
return
warnings=0
for m in modules:
warnings+=checkPath(os.path.join(path,m))
print("%d warnings occurred in pyflakes check" % warnings)
开发者ID:GINK03,项目名称:StaticPython,代码行数:10,代码来源:run_syntaxcheck.py
示例17: test_permissionDenied
def test_permissionDenied(self):
"""
If the a source file is not readable, this is reported on standard
error.
"""
sourcePath = fileWithContents('')
os.chmod(sourcePath, 0)
err = StringIO()
count = withStderrTo(err, lambda: checkPath(sourcePath))
self.assertEquals(count, 1)
self.assertEquals(
err.getvalue(), "%s: Permission denied\n" % (sourcePath,))
开发者ID:ImadBouirmane,项目名称:spyder,代码行数:12,代码来源:test_script.py
示例18: test_misencodedFile
def test_misencodedFile(self):
"""
If a source file contains bytes which cannot be decoded, this is
reported on stderr.
"""
source = """\
# coding: ascii
x = "\N{SNOWMAN}"
""".encode('utf-8')
sourcePath = fileWithContents(source)
err = StringIO()
count = withStderrTo(err, lambda: checkPath(sourcePath))
self.assertEquals(count, 1)
self.assertEquals(
err.getvalue(), "%s: problem decoding source\n" % (sourcePath,))
开发者ID:ImadBouirmane,项目名称:spyder,代码行数:15,代码来源:test_script.py
示例19: run
def run(self):
import os
try:
import pyflakes.scripts.pyflakes as flakes
except ImportError:
print("In order to run the audit, you need to have PyFlakes installed.")
sys.exit(-1)
dirs = (os.path.join(*d) for d in (m.split('.') for m in modules))
warns = 0
for dir in dirs:
for filename in os.listdir(dir):
if filename.endswith('.py') and filename != '__init__.py':
warns += flakes.checkPath(os.path.join(dir, filename))
if warns > 0:
print("Audit finished with total %d warnings" % warns)
开发者ID:vramana,项目名称:sympy,代码行数:15,代码来源:setup.py
示例20: test_checkPathNonExisting
def test_checkPathNonExisting(self):
"""
L{checkPath} handles non-existing files.
"""
err = StringIO()
try:
def mock_open(*k):
raise IOError(None, "No such file or directory")
pyflakes.open = mock_open
count = checkPath("extremo", stderr=err)
finally:
del pyflakes.open
self.assertEquals(err.getvalue(), "extremo: No such file or directory\n")
self.assertEquals(count, 1)
开发者ID:RonnyPfannschmidt-Attic,项目名称:pyflakes-old,代码行数:16,代码来源:test_script.py
注:本文中的pyflakes.scripts.pyflakes.checkPath函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论