当前位置: 首页>>代码示例>>Python>>正文


Python api.iterSourceCode函数代码示例

本文整理汇总了Python中pyflakes.api.iterSourceCode函数的典型用法代码示例。如果您正苦于以下问题:Python iterSourceCode函数的具体用法?Python iterSourceCode怎么用?Python iterSourceCode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了iterSourceCode函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_singleFile

 def test_singleFile(self):
     """
     If the directory contains one Python file, C{iterSourceCode} will find
     it.
     """
     childpath = self.makeEmptyFile('foo.py')
     self.assertEqual(list(iterSourceCode([self.tempdir])), [childpath])
开发者ID:liangsuilong,项目名称:pyflakes,代码行数:7,代码来源:test_api.py

示例2: test_explicitFiles

 def test_explicitFiles(self):
     """
     If one of the paths given to L{iterSourceCode} is not a directory but
     a file, it will include that in its output.
     """
     epath = self.makeEmptyFile("e.py")
     self.assertEqual(list(iterSourceCode([epath])), [epath])
开发者ID:yamatogun,项目名称:pyflakes,代码行数:7,代码来源:test_api.py

示例3: test_shebang

    def test_shebang(self):
        """
        Find Python files that don't end with `.py`, but contain a Python
        shebang.
        """
        python = os.path.join(self.tempdir, 'a')
        with open(python, 'w') as fd:
            fd.write('#!/usr/bin/env python\n')

        self.makeEmptyFile('b')

        with open(os.path.join(self.tempdir, 'c'), 'w') as fd:
            fd.write('hello\nworld\n')

        python2 = os.path.join(self.tempdir, 'd')
        with open(python2, 'w') as fd:
            fd.write('#!/usr/bin/env python2\n')

        python3 = os.path.join(self.tempdir, 'e')
        with open(python3, 'w') as fd:
            fd.write('#!/usr/bin/env python3\n')

        pythonw = os.path.join(self.tempdir, 'f')
        with open(pythonw, 'w') as fd:
            fd.write('#!/usr/bin/env pythonw\n')

        self.assertEqual(
            sorted(iterSourceCode([self.tempdir])),
            sorted([python, python2, python3, pythonw]))
开发者ID:Khan,项目名称:khan-linter,代码行数:29,代码来源:test_api.py

示例4: _check_recursive

def _check_recursive(paths, reporter):
    """
    The builtin recursive checker tries to check .pyc files.
    """
    num_warnings = 0
    for path in api.iterSourceCode(paths):
        if path.endswith('.py'):
            num_warnings += api.checkPath(path, reporter)
    return num_warnings
开发者ID:360yln,项目名称:django-cms-2.4,代码行数:9,代码来源:static_analysis.py

示例5: run

    def run(self):
        reporter = ProspectorReporter(ignore=self.ignore_codes)

        for filepath in iterSourceCode(self._paths):
            if any([ip.search(filepath) for ip in self._ignores]):
                continue

            checkPath(filepath, reporter)

        return reporter.get_messages()
开发者ID:marciusvinicius,项目名称:prospector,代码行数:10,代码来源:__init__.py

示例6: test_recurses

 def test_recurses(self):
     """
     If the Python files are hidden deep down in child directories, we will
     find them.
     """
     os.mkdir(os.path.join(self.tempdir, "foo"))
     apath = self.makeEmptyFile("foo", "a.py")
     os.mkdir(os.path.join(self.tempdir, "bar"))
     bpath = self.makeEmptyFile("bar", "b.py")
     cpath = self.makeEmptyFile("c.py")
     self.assertEqual(sorted(iterSourceCode([self.tempdir])), sorted([apath, bpath, cpath]))
开发者ID:yamatogun,项目名称:pyflakes,代码行数:11,代码来源:test_api.py

示例7: test_multipleDirectories

 def test_multipleDirectories(self):
     """
     L{iterSourceCode} can be given multiple directories.  It will recurse
     into each of them.
     """
     foopath = os.path.join(self.tempdir, "foo")
     barpath = os.path.join(self.tempdir, "bar")
     os.mkdir(foopath)
     apath = self.makeEmptyFile("foo", "a.py")
     os.mkdir(barpath)
     bpath = self.makeEmptyFile("bar", "b.py")
     self.assertEqual(sorted(iterSourceCode([foopath, barpath])), sorted([apath, bpath]))
开发者ID:yamatogun,项目名称:pyflakes,代码行数:12,代码来源:test_api.py

示例8: test_recurses

 def test_recurses(self):
     """
     If the Python files are hidden deep down in child directories, we will
     find them.
     """
     os.mkdir(os.path.join(self.tempdir, 'foo'))
     apath = self.makeEmptyFile('foo', 'a.py')
     os.mkdir(os.path.join(self.tempdir, 'bar'))
     bpath = self.makeEmptyFile('bar', 'b.py')
     cpath = self.makeEmptyFile('c.py')
     self.assertEqual(
         sorted(iterSourceCode([self.tempdir])),
         sorted([apath, bpath, cpath]))
开发者ID:liangsuilong,项目名称:pyflakes,代码行数:13,代码来源:test_api.py

示例9: test_emptyDirectory

 def test_emptyDirectory(self):
     """
     There are no Python files in an empty directory.
     """
     self.assertEqual(list(iterSourceCode([self.tempdir])), [])
开发者ID:liangsuilong,项目名称:pyflakes,代码行数:5,代码来源:test_api.py

示例10: test_onlyPythonSource

 def test_onlyPythonSource(self):
     """
     Files that are not Python source files are not included.
     """
     self.makeEmptyFile('foo.pyc')
     self.assertEqual(list(iterSourceCode([self.tempdir])), [])
开发者ID:liangsuilong,项目名称:pyflakes,代码行数:6,代码来源:test_api.py

示例11:

"""
开发者ID:letouriste001,项目名称:SmartForest_2.0,代码行数:1,代码来源:test_api.py


注:本文中的pyflakes.api.iterSourceCode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。