def dolint(self, filename): exceptions = set() buffer = csio() reporter = text.ParseableTextReporter(output=buffer) options = list(self.config.get('options')) options.append(filename) lint.Run(options, reporter=reporter, exit=False) output = buffer.getvalue() buffer.close() for line in output.splitlines(): if self.idline.match(line): continue if self.detail.match(line): mo = self.detail.search(line) tokens = mo.groups() fn = tokens[0] ln = tokens[1] code = tokens[2] codename = tokens[3] func = tokens[4] message = tokens[5] if not self.config.ignore(fn, code, codename, message): exceptions.add((fn, ln, code, codename, func, message)) return exceptions
def run_pylint(filename, rcfile=None): """run pylint check.""" disable = ["E1103", # maybe-no-member "W0142", # star-args "W1201", # logging-not-lazy "I0011", # locally-disabled "I0012", # locally-enabled "R0801", # duplicate-code "R0901", # too-many-ancestors "R0902", # too-many-instance-attributes "R0903", # too-few-public-methods "R0904", # too-many-public-methods "R0921", # abstract-class-not-used "R0922"] # abstract-class-little-used enable = ["W0511"] # fixme args = [ "-r", "n", "--persistent=n", "-d", ",".join(disable), "-e", ",".join(enable)] if rcfile: args.append("--rcfile=%s" % rcfile) kwargs = dict(exit=False) try: kwargs['reporter'] = text.TextReporter(sys.stdout) kwargs['reporter'].line_format # pylint: disable=pointless-statement args += ["--msg-template", "{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}"] except AttributeError: kwargs['reporter'] = text.ParseableTextReporter(sys.stdout) args += ["-f", "parseable", "-i", "y"] lint.Run(args + [filename], **kwargs)
def run_pylint(): buff = StringIO() reporter = text.ParseableTextReporter(output=buff) args = ["--include-ids=y", "-E", "savanna"] lint.Run(args, reporter=reporter, exit=False) val = buff.getvalue() buff.close() return val
def run_pylint(): buff = StringIO() reporter = text.ParseableTextReporter(output=buff) args = ["--include-ids=y", "--errors-only", "rbd_iscsi_client"] lint.Run(args, reporter=reporter, exit=False) val = buff.getvalue() buff.close() return val
def run(config, *args): """ Run pylint """ try: from pylint import lint from pylint.reporters import text except ImportError: return 2 if config is None: config = _shell.native('pylintrc') argv = [ '--rcfile', config, '--reports', 'no', ] stream = FilterStream(_term.terminfo()) old_stderr = _sys.stderr try: # pylint: disable = E1101 _sys.stderr = stream from pylint import __pkginfo__ if __pkginfo__.numversion >= (1, 0, 0): reporter = text.TextReporter(stream) argv.extend([ '--msg-template', '{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}' ]) else: argv.extend( ['--output-format', 'parseable', '--include-ids', 'yes']) if __pkginfo__.numversion < (0, 13): lint.REPORTER_OPT_MAP['parseable'] = \ lambda: text.TextReporter2(stream) reporter = text.TextReporter2(stream) else: reporter = text.ParseableTextReporter(stream) lint.REPORTER_OPT_MAP['parseable'] = lambda: reporter for path in args: try: try: lint.Run(argv + [path], reporter=reporter) except SystemExit: pass # don't accept the exit. strange errors happen... if stream.written: print() stream.written = False except KeyboardInterrupt: print() raise finally: _sys.stderr = old_stderr return 0
def run_pylint(): buff = StringIO() reporter = text.ParseableTextReporter(output=buff) args = ["-rn", "--disable=all", "--enable=" + ",".join(ENABLED_CODES), "murano"] lint.Run(args, reporter=reporter, exit=False) val = buff.getvalue() buff.close() return val