當前位置: 首頁>>代碼示例>>Python>>正文


Python interfaces.IAstroidChecker方法代碼示例

本文整理匯總了Python中pylint.interfaces.IAstroidChecker方法的典型用法代碼示例。如果您正苦於以下問題:Python interfaces.IAstroidChecker方法的具體用法?Python interfaces.IAstroidChecker怎麽用?Python interfaces.IAstroidChecker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pylint.interfaces的用法示例。


在下文中一共展示了interfaces.IAstroidChecker方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: register_checker

# 需要導入模塊: from pylint import interfaces [as 別名]
# 或者: from pylint.interfaces import IAstroidChecker [as 別名]
def register_checker(self, checker):
        """register a new checker

        checker is an object implementing IRawChecker or / and IAstroidChecker
        """
        assert checker.priority <= 0, 'checker priority can\'t be >= 0'
        self._checkers[checker.name].append(checker)
        for r_id, r_title, r_cb in checker.reports:
            self.register_report(r_id, r_title, r_cb, checker)
        self.register_options_provider(checker)
        if hasattr(checker, 'msgs'):
            self.msgs_store.register_messages(checker)
        checker.load_defaults()

        # Register the checker, but disable all of its messages.
        # TODO(cpopa): we should have a better API for this.
        if not getattr(checker, 'enabled', True):
            self.disable(checker.name) 
開發者ID:AtomLinter,項目名稱:linter-pylama,代碼行數:20,代碼來源:lint.py

示例2: register_checker

# 需要導入模塊: from pylint import interfaces [as 別名]
# 或者: from pylint.interfaces import IAstroidChecker [as 別名]
def register_checker(self, checker):
        """register a new checker

        checker is an object implementing IRawChecker or / and IAstroidChecker
        """
        assert checker.priority <= 0, "checker priority can't be >= 0"
        self._checkers[checker.name].append(checker)
        for r_id, r_title, r_cb in checker.reports:
            self.register_report(r_id, r_title, r_cb, checker)
        self.register_options_provider(checker)
        if hasattr(checker, "msgs"):
            self.msgs_store.register_messages_from_checker(checker)
        checker.load_defaults()

        # Register the checker, but disable all of its messages.
        # TODO(cpopa): we should have a better API for this.
        if not getattr(checker, "enabled", True):
            self.disable(checker.name) 
開發者ID:sofia-netsurv,項目名稱:python-netsurv,代碼行數:20,代碼來源:lint.py

示例3: _do_check

# 需要導入模塊: from pylint import interfaces [as 別名]
# 或者: from pylint.interfaces import IAstroidChecker [as 別名]
def _do_check(self, files_or_modules):
        walker = utils.PyLintASTWalker(self)
        _checkers = self.prepare_checkers()
        tokencheckers = [c for c in _checkers
                         if interfaces.implements(c, interfaces.ITokenChecker)
                         and c is not self]
        rawcheckers = [c for c in _checkers
                       if interfaces.implements(c, interfaces.IRawChecker)]
        # notify global begin
        for checker in _checkers:
            checker.open()
            if interfaces.implements(checker, interfaces.IAstroidChecker):
                walker.add_checker(checker)
        # build ast and check modules or packages
        for descr in self.expand_files(files_or_modules):
            modname, filepath, is_arg = descr['name'], descr['path'], descr['isarg']
            if not self.should_analyze_file(modname, filepath, is_argument=is_arg):
                continue

            self.set_current_module(modname, filepath)
            # get the module representation
            ast_node = self.get_ast(filepath, modname)
            if ast_node is None:
                continue
            # XXX to be correct we need to keep module_msgs_state for every
            # analyzed module (the problem stands with localized messages which
            # are only detected in the .close step)
            self.file_state = utils.FileState(descr['basename'])
            self._ignore_file = False
            # fix the current file (if the source file was not available or
            # if it's actually a c extension)
            self.current_file = ast_node.file # pylint: disable=maybe-no-member
            self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
            # warn about spurious inline messages handling
            spurious_messages = self.file_state.iter_spurious_suppression_messages(self.msgs_store)
            for msgid, line, args in spurious_messages:
                self.add_message(msgid, line, None, args)
        # notify global end
        self.stats['statement'] = walker.nbstatements
        for checker in reversed(_checkers):
            checker.close() 
開發者ID:AtomLinter,項目名稱:linter-pylama,代碼行數:43,代碼來源:lint.py

示例4: check_astroid_module

# 需要導入模塊: from pylint import interfaces [as 別名]
# 或者: from pylint.interfaces import IAstroidChecker [as 別名]
def check_astroid_module(self, ast_node, walker,
                             rawcheckers, tokencheckers):
        """Check a module from its astroid representation."""
        try:
            tokens = utils.tokenize_module(ast_node)
        except tokenize.TokenError as ex:
            self.add_message('syntax-error', line=ex.args[1][0], args=ex.args[0])
            return None

        if not ast_node.pure_python:
            self.add_message('raw-checker-failed', args=ast_node.name)
        else:
            #assert astroid.file.endswith('.py')
            # invoke ITokenChecker interface on self to fetch module/block
            # level options
            self.process_tokens(tokens)
            if self._ignore_file:
                return False
            # walk ast to collect line numbers
            self.file_state.collect_block_lines(self.msgs_store, ast_node)
            # run raw and tokens checkers
            for checker in rawcheckers:
                checker.process_module(ast_node)
            for checker in tokencheckers:
                checker.process_tokens(tokens)
        # generate events to astroid checkers
        walker.walk(ast_node)
        return True

    # IAstroidChecker interface ################################################# 
開發者ID:AtomLinter,項目名稱:linter-pylama,代碼行數:32,代碼來源:lint.py

示例5: register

# 需要導入模塊: from pylint import interfaces [as 別名]
# 或者: from pylint.interfaces import IAstroidChecker [as 別名]
def register(linter):
  """pylint will call this func to register all our checkers"""
  # Walk all the classes in this module and register ours.
  this_module = sys.modules[__name__]
  for member in dir(this_module):
    if (not member.endswith('Checker') or
        member in ('BaseChecker', 'IAstroidChecker')):
      continue
    cls = getattr(this_module, member)
    linter.register_checker(cls(linter)) 
開發者ID:JeetShetty,項目名稱:GreenPiThumb,代碼行數:12,代碼來源:lint.py

示例6: check_astroid_module

# 需要導入模塊: from pylint import interfaces [as 別名]
# 或者: from pylint.interfaces import IAstroidChecker [as 別名]
def check_astroid_module(self, ast_node, walker, rawcheckers, tokencheckers):
        """Check a module from its astroid representation."""
        try:
            tokens = utils.tokenize_module(ast_node)
        except tokenize.TokenError as ex:
            self.add_message("syntax-error", line=ex.args[1][0], args=ex.args[0])
            return None

        if not ast_node.pure_python:
            self.add_message("raw-checker-failed", args=ast_node.name)
        else:
            # assert astroid.file.endswith('.py')
            # invoke ITokenChecker interface on self to fetch module/block
            # level options
            self.process_tokens(tokens)
            if self._ignore_file:
                return False
            # walk ast to collect line numbers
            self.file_state.collect_block_lines(self.msgs_store, ast_node)
            # run raw and tokens checkers
            for checker in rawcheckers:
                checker.process_module(ast_node)
            for checker in tokencheckers:
                checker.process_tokens(tokens)
        # generate events to astroid checkers
        walker.walk(ast_node)
        return True

    # IAstroidChecker interface ################################################# 
開發者ID:sofia-netsurv,項目名稱:python-netsurv,代碼行數:31,代碼來源:lint.py

示例7: test_pylint_visit_method_taken_in_account

# 需要導入模塊: from pylint import interfaces [as 別名]
# 或者: from pylint.interfaces import IAstroidChecker [as 別名]
def test_pylint_visit_method_taken_in_account(linter):
    class CustomChecker(checkers.BaseChecker):
        __implements__ = interfaces.IAstroidChecker
        name = "custom"
        msgs = {"W9999": ("", "custom", "")}

        @check_messages("custom")
        def visit_class(self, _):
            pass

    linter.register_checker(CustomChecker(linter))
    linter.open()
    out = StringIO()
    linter.set_reporter(text.TextReporter(out))
    linter.check("abc") 
開發者ID:sofia-netsurv,項目名稱:python-netsurv,代碼行數:17,代碼來源:unittest_lint.py

示例8: _do_check

# 需要導入模塊: from pylint import interfaces [as 別名]
# 或者: from pylint.interfaces import IAstroidChecker [as 別名]
def _do_check(self, files_or_modules):
        walker = utils.PyLintASTWalker(self)
        _checkers = self.prepare_checkers()
        tokencheckers = [
            c
            for c in _checkers
            if interfaces.implements(c, interfaces.ITokenChecker) and c is not self
        ]
        rawcheckers = [
            c for c in _checkers if interfaces.implements(c, interfaces.IRawChecker)
        ]
        # notify global begin
        for checker in _checkers:
            checker.open()
            if interfaces.implements(checker, interfaces.IAstroidChecker):
                walker.add_checker(checker)
        # build ast and check modules or packages
        for descr in self.expand_files(files_or_modules):
            modname, filepath, is_arg = descr["name"], descr["path"], descr["isarg"]
            if not self.should_analyze_file(modname, filepath, is_argument=is_arg):
                continue

            self.set_current_module(modname, filepath)
            # get the module representation
            ast_node = self.get_ast(filepath, modname)
            if ast_node is None:
                continue
            # XXX to be correct we need to keep module_msgs_state for every
            # analyzed module (the problem stands with localized messages which
            # are only detected in the .close step)
            self.file_state = utils.FileState(descr["basename"])
            self._ignore_file = False
            # fix the current file (if the source file was not available or
            # if it's actually a c extension)
            self.current_file = ast_node.file  # pylint: disable=maybe-no-member
            self.check_astroid_module(ast_node, walker, rawcheckers, tokencheckers)
            # warn about spurious inline messages handling
            spurious_messages = self.file_state.iter_spurious_suppression_messages(
                self.msgs_store
            )
            for msgid, line, args in spurious_messages:
                self.add_message(msgid, line, None, args)
        # notify global end
        self.stats["statement"] = walker.nbstatements
        for checker in reversed(_checkers):
            checker.close() 
開發者ID:sofia-netsurv,項目名稱:python-netsurv,代碼行數:48,代碼來源:lint.py


注:本文中的pylint.interfaces.IAstroidChecker方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。