• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python config.find_pylintrc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_pylintrc_parentdir_no_package

    def test_pylintrc_parentdir_no_package(self):
        chroot = tempfile.mkdtemp()

        # Get real path of tempfile, otherwise test fail on mac os x
        cdir = getcwd()
        chdir(chroot)
        chroot = abspath('.')
        chdir(cdir)

        fake_home = tempfile.mkdtemp('fake-home')
        home = os.environ['HOME']
        os.environ['HOME'] = fake_home
        try:
            create_files(['a/pylintrc', 'a/b/pylintrc', 'a/b/c/d/__init__.py'], chroot)
            os.chdir(chroot)
            self.assertEqual(config.find_pylintrc(), None)
            results = {'a'       : join(chroot, 'a', 'pylintrc'),
                       'a/b'     : join(chroot, 'a', 'b', 'pylintrc'),
                       'a/b/c'   : None,
                       'a/b/c/d' : None,
                       }
            for basedir, expected in results.items():
                os.chdir(join(chroot, basedir))
                self.assertEqual(config.find_pylintrc(), expected)
        finally:
            os.environ['HOME'] = home
            rmtree(fake_home, ignore_errors=True)
            os.chdir(HERE)
            rmtree(chroot)
开发者ID:aras0,项目名称:porownywarka-ofert,代码行数:29,代码来源:unittest_lint.py


示例2: test_pylintrc_parentdir

def test_pylintrc_parentdir():
    with tempdir() as chroot:

        create_files(
            [
                "a/pylintrc",
                "a/b/__init__.py",
                "a/b/pylintrc",
                "a/b/c/__init__.py",
                "a/b/c/d/__init__.py",
                "a/b/c/d/e/.pylintrc",
            ]
        )
        with fake_home():
            assert config.find_pylintrc() is None
        results = {
            "a": join(chroot, "a", "pylintrc"),
            "a/b": join(chroot, "a", "b", "pylintrc"),
            "a/b/c": join(chroot, "a", "b", "pylintrc"),
            "a/b/c/d": join(chroot, "a", "b", "pylintrc"),
            "a/b/c/d/e": join(chroot, "a", "b", "c", "d", "e", ".pylintrc"),
        }
        for basedir, expected in results.items():
            os.chdir(join(chroot, basedir))
            assert config.find_pylintrc() == expected
开发者ID:bluesheeptoken,项目名称:pylint,代码行数:25,代码来源:unittest_lint.py


示例3: test_pylintrc_parentdir

 def test_pylintrc_parentdir(self):
     chroot = tempfile.mkdtemp()
     try:
         create_files(['a/pylintrc', 'a/b/__init__.py', 'a/b/pylintrc',
                       'a/b/c/__init__.py', 'a/b/c/d/__init__.py'], chroot)
         os.chdir(chroot)
         fake_home = tempfile.mkdtemp('fake-home')
         home = os.environ['HOME']
         try:
             os.environ['HOME'] = fake_home
             self.assertEqual(config.find_pylintrc(), None)
         finally:
             os.environ['HOME'] = home
             os.rmdir(fake_home)
         results = {'a'       : join(chroot, 'a', 'pylintrc'),
                    'a/b'     : join(chroot, 'a', 'b', 'pylintrc'),
                    'a/b/c'   : join(chroot, 'a', 'b', 'pylintrc'),
                    'a/b/c/d' : join(chroot, 'a', 'b', 'pylintrc'),
                    }
         for basedir, expected in results.items():
             os.chdir(join(chroot, basedir))
             self.assertEqual(config.find_pylintrc(), expected)
     finally:
         os.chdir(HERE)
         rmtree(chroot)
开发者ID:gregburek,项目名称:Coding-Out-of-a-Wet-Paper-Bag,代码行数:25,代码来源:unittest_lint.py


示例4: test_pylintrc

 def test_pylintrc(self):
     try:
         self.assertEquals(config.find_pylintrc(), None)
         os.environ['PYLINTRC'] = join(tempfile.gettempdir(), '.pylintrc')
         self.assertEquals(config.find_pylintrc(), None)
         os.environ['PYLINTRC'] = '.'
         self.assertEquals(config.find_pylintrc(), None)
     finally:
         os.environ.pop('PYLINTRC', '')
         reload(config)
开发者ID:bmcharek,项目名称:opendata101-workshops,代码行数:10,代码来源:unittest_lint.py


示例5: test_pylintrc

 def test_pylintrc(self):
     with fake_home():
         try:
             self.assertEqual(config.find_pylintrc(), None)
             os.environ['PYLINTRC'] = join(tempfile.gettempdir(),
                                           '.pylintrc')
             self.assertEqual(config.find_pylintrc(), None)
             os.environ['PYLINTRC'] = '.'
             self.assertEqual(config.find_pylintrc(), None)
         finally:
             reload_module(config)
开发者ID:The-Compiler,项目名称:pylint,代码行数:11,代码来源:unittest_lint.py


示例6: test_pylintrc

def test_pylintrc():
    with fake_home():
        current_dir = getcwd()
        chdir(os.path.dirname(os.path.abspath(sys.executable)))
        try:
            assert config.find_pylintrc() is None
            os.environ["PYLINTRC"] = join(tempfile.gettempdir(), ".pylintrc")
            assert config.find_pylintrc() is None
            os.environ["PYLINTRC"] = "."
            assert config.find_pylintrc() is None
        finally:
            chdir(current_dir)
            reload(config)
开发者ID:bluesheeptoken,项目名称:pylint,代码行数:13,代码来源:unittest_lint.py


示例7: test_pylintrc_parentdir_no_package

 def test_pylintrc_parentdir_no_package(self):
     with tempdir() as chroot:
         with fake_home():
             create_files(['a/pylintrc', 'a/b/pylintrc', 'a/b/c/d/__init__.py'])
             self.assertEqual(config.find_pylintrc(), None)
             results = {'a'       : join(chroot, 'a', 'pylintrc'),
                        'a/b'     : join(chroot, 'a', 'b', 'pylintrc'),
                        'a/b/c'   : None,
                        'a/b/c/d' : None,
                        }
             for basedir, expected in results.items():
                 os.chdir(join(chroot, basedir))
                 self.assertEqual(config.find_pylintrc(), expected)
开发者ID:The-Compiler,项目名称:pylint,代码行数:13,代码来源:unittest_lint.py


示例8: test_pylintrc

 def test_pylintrc(self):
     fake_home = tempfile.mkdtemp("fake-home")
     home = os.environ[HOME]
     try:
         os.environ[HOME] = fake_home
         self.assertEqual(config.find_pylintrc(), None)
         os.environ["PYLINTRC"] = join(tempfile.gettempdir(), ".pylintrc")
         self.assertEqual(config.find_pylintrc(), None)
         os.environ["PYLINTRC"] = "."
         self.assertEqual(config.find_pylintrc(), None)
     finally:
         os.environ.pop("PYLINTRC", "")
         os.environ[HOME] = home
         rmtree(fake_home, ignore_errors=True)
         reload(config)
开发者ID:si618,项目名称:pi-time,代码行数:15,代码来源:unittest_lint.py


示例9: test_pylintrc

 def test_pylintrc(self):
     fake_home = tempfile.mkdtemp('fake-home')
     home = os.environ['HOME']
     try:
         os.environ['HOME'] = fake_home
         self.assertEqual(config.find_pylintrc(), None)
         os.environ['PYLINTRC'] = join(tempfile.gettempdir(), '.pylintrc')
         self.assertEqual(config.find_pylintrc(), None)
         os.environ['PYLINTRC'] = '.'
         self.assertEqual(config.find_pylintrc(), None)
     finally:
         os.environ.pop('PYLINTRC', '')
         os.environ['HOME'] = home
         rmtree(fake_home, ignore_errors=True)
         reload(config)
开发者ID:aras0,项目名称:porownywarka-ofert,代码行数:15,代码来源:unittest_lint.py


示例10: test_pylintrc_parentdir

def test_pylintrc_parentdir():
    with tempdir() as chroot:

        create_files(['a/pylintrc', 'a/b/__init__.py', 'a/b/pylintrc',
                      'a/b/c/__init__.py', 'a/b/c/d/__init__.py',
                      'a/b/c/d/e/.pylintrc'])
        with fake_home():
            assert config.find_pylintrc() is None
        results = {'a'       : join(chroot, 'a', 'pylintrc'),
                   'a/b'     : join(chroot, 'a', 'b', 'pylintrc'),
                   'a/b/c'   : join(chroot, 'a', 'b', 'pylintrc'),
                   'a/b/c/d' : join(chroot, 'a', 'b', 'pylintrc'),
                   'a/b/c/d/e' : join(chroot, 'a', 'b', 'c', 'd', 'e', '.pylintrc'),
                   }
        for basedir, expected in results.items():
            os.chdir(join(chroot, basedir))
            assert config.find_pylintrc() == expected
开发者ID:Mariatta,项目名称:pylint,代码行数:17,代码来源:unittest_lint.py


示例11: test_pylintrc_parentdir_no_package

 def test_pylintrc_parentdir_no_package(self):
     chroot = tempfile.mkdtemp()
     try:
         create_files(['a/pylintrc', 'a/b/pylintrc', 'a/b/c/d/__init__.py'], chroot)
         os.chdir(chroot)
         self.assertEquals(config.find_pylintrc(), None)
         results = {'a'       : join(chroot, 'a', 'pylintrc'),
                    'a/b'     : join(chroot, 'a', 'b', 'pylintrc'),
                    'a/b/c'   : None, 
                    'a/b/c/d' : None, 
                    }
         for basedir, expected in results.items():
             os.chdir(join(chroot, basedir))
             self.assertEquals(config.find_pylintrc(), expected)
     finally:
         os.chdir(HERE)
         shutil.rmtree(chroot)
开发者ID:bmcharek,项目名称:opendata101-workshops,代码行数:17,代码来源:unittest_lint.py


示例12: test_pylintrc_parentdir_no_package

 def test_pylintrc_parentdir_no_package(self):
     with tempdir() as chroot:
         fake_home = tempfile.mkdtemp('fake-home')
         home = os.environ[HOME]
         os.environ[HOME] = fake_home
         try:
             create_files(['a/pylintrc', 'a/b/pylintrc', 'a/b/c/d/__init__.py'])
             self.assertEqual(config.find_pylintrc(), None)
             results = {'a'       : join(chroot, 'a', 'pylintrc'),
                        'a/b'     : join(chroot, 'a', 'b', 'pylintrc'),
                        'a/b/c'   : None,
                        'a/b/c/d' : None,
                        }
             for basedir, expected in results.items():
                 os.chdir(join(chroot, basedir))
                 self.assertEqual(config.find_pylintrc(), expected)
         finally:
             os.environ[HOME] = home
             rmtree(fake_home, ignore_errors=True)
开发者ID:balagopalraj,项目名称:clearlinux,代码行数:19,代码来源:unittest_lint.py


示例13: test_pylintrc_parentdir_no_package

 def test_pylintrc_parentdir_no_package(self):
     with tempdir() as chroot:
         fake_home = tempfile.mkdtemp("fake-home")
         home = os.environ[HOME]
         os.environ[HOME] = fake_home
         try:
             create_files(["a/pylintrc", "a/b/pylintrc", "a/b/c/d/__init__.py"])
             self.assertEqual(config.find_pylintrc(), None)
             results = {
                 "a": join(chroot, "a", "pylintrc"),
                 "a/b": join(chroot, "a", "b", "pylintrc"),
                 "a/b/c": None,
                 "a/b/c/d": None,
             }
             for basedir, expected in results.items():
                 os.chdir(join(chroot, basedir))
                 self.assertEqual(config.find_pylintrc(), expected)
         finally:
             os.environ[HOME] = home
             rmtree(fake_home, ignore_errors=True)
开发者ID:si618,项目名称:pi-time,代码行数:20,代码来源:unittest_lint.py


示例14: test_pylintrc_parentdir

    def test_pylintrc_parentdir(self):
        with tempdir() as chroot:

            create_files(['a/pylintrc', 'a/b/__init__.py', 'a/b/pylintrc',
                          'a/b/c/__init__.py', 'a/b/c/d/__init__.py'])
            fake_home = tempfile.mkdtemp('fake-home')
            home = os.environ[HOME]
            try:
                os.environ[HOME] = fake_home
                self.assertEqual(config.find_pylintrc(), None)
            finally:
                os.environ[HOME] = home
                os.rmdir(fake_home)
            results = {'a'       : join(chroot, 'a', 'pylintrc'),
                       'a/b'     : join(chroot, 'a', 'b', 'pylintrc'),
                       'a/b/c'   : join(chroot, 'a', 'b', 'pylintrc'),
                       'a/b/c/d' : join(chroot, 'a', 'b', 'pylintrc'),
                       }
            for basedir, expected in list(results.items()):
                os.chdir(join(chroot, basedir))
                self.assertEqual(config.find_pylintrc(), expected)
开发者ID:Magzhan123,项目名称:disqus_be,代码行数:21,代码来源:unittest_lint.py


示例15: configure

    def configure(self, prospector_config, found_files):

        config_messages = []
        extra_sys_path = found_files.get_minimal_syspath()

        # create a list of packages, but don't include packages which are
        # subpackages of others as checks will be duplicated
        packages = [p.split(os.path.sep) for p in found_files.iter_package_paths(abspath=False)]
        packages.sort(key=len)
        check_paths = set()
        for package in packages:
            package_path = os.path.join(*package)
            if len(package) == 1:
                check_paths.add(package_path)
                continue
            for i in range(1, len(package)):
                if os.path.join(*package[:-i]) in check_paths:
                    break
            else:
                check_paths.add(package_path)

        for filepath in found_files.iter_module_paths(abspath=False):
            package = os.path.dirname(filepath).split(os.path.sep)
            for i in range(0, len(package)):
                if os.path.join(*package[:i + 1]) in check_paths:
                    break
            else:
                check_paths.add(filepath)

        check_paths = [found_files.to_absolute_path(p) for p in check_paths]

        # insert the target path into the system path to get correct behaviour
        self._orig_sys_path = sys.path
        # note: we prepend, so that modules are preferentially found in the
        # path given as an argument. This prevents problems where we are
        # checking a module which is already on sys.path before this
        # manipulation - for example, if we are checking 'requests' in a local
        # checkout, but 'requests' is already installed system wide, pylint
        # will discover the system-wide modules first if the local checkout
        # does not appear first in the path
        sys.path = list(extra_sys_path) + sys.path

        ext_found = False
        configured_by = None

        linter = ProspectorLinter(found_files)
        if prospector_config.use_external_config('pylint'):
            # try to find a .pylintrc
            pylintrc = prospector_config.external_config_location('pylint')
            if pylintrc is None:
                pylintrc = find_pylintrc()
            if pylintrc is None:
                pylintrc_path = os.path.join(prospector_config.workdir, '.pylintrc')
                if os.path.exists(pylintrc_path):
                    pylintrc = pylintrc_path

            if pylintrc is not None:
                # load it!
                configured_by = pylintrc
                ext_found = True

                self._args = linter.load_command_line_configuration(check_paths)
                config_messages += self._pylintrc_configure(pylintrc, linter)

        if not ext_found:
            linter.reset_options()
            self._args = linter.load_command_line_configuration(check_paths)
            self._prospector_configure(prospector_config, linter)

        # Pylint 1.4 introduced the idea of explicitly specifying which C-extensions
        # to load. This is because doing so allows them to execute any code whatsoever,
        # which is considered to be unsafe. The following option turns off this, allowing
        # any extension to load again, since any setup.py can execute arbitrary code and
        # the safety gained through this approach seems minimal. Leaving it on means
        # that the inference engine cannot do much inference on modules with C-extensions
        # which is a bit useless.
        linter.set_option('unsafe-load-any-extension', True)

        # we don't want similarity reports right now
        linter.disable('similarities')

        # use the collector 'reporter' to simply gather the messages
        # given by PyLint
        self._collector = Collector(linter.msgs_store)
        linter.set_reporter(self._collector)

        self._linter = linter
        return configured_by, config_messages
开发者ID:pennyarcade,项目名称:py_pov,代码行数:88,代码来源:__init__.py


示例16: check_repo

def check_repo(
        limit, pylint='pylint', pylintrc=None, pylint_params='',
        suppress_report=False, always_show_violations=False, ignored_files=None):
    """ Main function doing the checks

    :type limit: float
    :param limit: Minimum score to pass the commit
    :type pylint: str
    :param pylint: Path to pylint executable
    :type pylintrc: str
    :param pylintrc: Path to pylintrc file
    :type pylint_params: str
    :param pylint_params: Custom pylint parameters to add to the pylint command
    :type suppress_report: bool
    :param suppress_report: Suppress report if score is below limit
    :type always_show_violations: bool
    :param always_show_violations: Show violations in case of pass as well
    :type ignored_files: list
    :param ignored_files: List of files to exclude from the validation
    """
    # Lists are mutable and should not be assigned in function arguments
    if ignored_files is None:
        ignored_files = []

    # List of checked files and their results
    python_files = []

    # Set the exit code
    all_filed_passed = True

    if pylintrc is None:
        # If no config is found, use the old default '.pylintrc'
        pylintrc = pylint_config.find_pylintrc() or '.pylintrc'

    # Stash any unstaged changes while we look at the tree
    with _stash_unstaged():
        # Find Python files
        for filename in _get_list_of_committed_files():
            try:
                if _is_python_file(filename) and \
                        not _is_ignored(filename, ignored_files):
                    python_files.append((filename, None))
            except IOError:
                print('File not found (probably deleted): {}\t\tSKIPPED'.format(
                    filename))

        # Don't do anything if there are no Python files
        if len(python_files) == 0:
            sys.exit(0)

        # Load any pre-commit-hooks options from a .pylintrc file (if there is one)
        if os.path.exists(pylintrc):
            conf = configparser.SafeConfigParser()
            conf.read(pylintrc)
            if conf.has_option('pre-commit-hook', 'command'):
                pylint = conf.get('pre-commit-hook', 'command')
            if conf.has_option('pre-commit-hook', 'params'):
                pylint_params += ' ' + conf.get('pre-commit-hook', 'params')
            if conf.has_option('pre-commit-hook', 'limit'):
                limit = float(conf.get('pre-commit-hook', 'limit'))

        # Pylint Python files
        i = 1
        for python_file, score in python_files:
            # Allow __init__.py files to be completely empty
            if os.path.basename(python_file) == '__init__.py':
                if os.stat(python_file).st_size == 0:
                    print(
                        'Skipping pylint on {} (empty __init__.py)..'
                        '\tSKIPPED'.format(python_file))

                    # Bump parsed files
                    i += 1
                    continue

            # Start pylinting
            sys.stdout.write("Running pylint on {} (file {}/{})..\t".format(
                python_file, i, len(python_files)))
            sys.stdout.flush()
            try:
                command = [pylint]
                if pylint_params:
                    command += pylint_params.split()
                    if '--rcfile' not in pylint_params:
                        command.append('--rcfile={}'.format(pylintrc))
                else:
                    command.append('--rcfile={}'.format(pylintrc))

                command.append(python_file)
                proc = subprocess.Popen(
                    command,
                    stdout=subprocess.PIPE,
                    stderr=subprocess.PIPE)

                out, _ = proc.communicate()
            except OSError:
                print("\nAn error occurred. Is pylint installed?")
                sys.exit(1)

            # Verify the score
#.........这里部分代码省略.........
开发者ID:JoshLabs,项目名称:git-pylint-commit-hook,代码行数:101,代码来源:commit_hook.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python lint.fix_import_path函数代码示例发布时间:2022-05-25
下一篇:
Python utils.safe_infer函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap