def main(): """ Main """ basedir, libdir = None, None accept_opts = True args = [] for arg in _sys.argv[1:]: if accept_opts: if arg == "--": accept_opts = False continue elif arg == "-q": term.write = term.green = term.red = term.yellow = term.announce = lambda fmt, **kwargs: None continue elif arg == "-p": info = {} for key in term.terminfo(): info[key] = "" info["ERASE"] = "\n" term.terminfo.info = info continue elif arg.startswith("-"): _sys.stderr.write("Unrecognized option %r\n" % (arg,)) return 2 args.append(arg) if len(args) > 2: _sys.stderr.write("Too many arguments\n") return 2 elif len(args) < 1: _sys.stderr.write("Missing arguments\n") return 2 basedir = args[0] if len(args) > 1: libdir = args[1] return run_tests(basedir, libdir)
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(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(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('pylint.conf') argv = ['--rcfile', config, '--reports', 'no', '--output-format', 'parseable', '--include-ids', 'yes' ] stream = FilterStream(_term.terminfo()) old_stderr = _sys.stderr try: # pylint: disable = E1101 _sys.stderr = stream from pylint import __pkginfo__ if __pkginfo__.numversion < (0, 13): # The lint tool is not very user friendly, so we need a hack here. 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 main(): """ Main """ basedir, libdir = None, None accept_opts = True args = [] for arg in _sys.argv[1:]: if accept_opts: if arg == '--': accept_opts = False continue elif arg == '-q': term.write = term.green = term.red = term.yellow = \ term.announce = \ lambda fmt, **kwargs: None continue elif arg == '-p': info = {} for key in term.terminfo(): info[key] = '' info['ERASE'] = '\n' term.terminfo.info = info continue elif arg.startswith('-'): _sys.stderr.write("Unrecognized option %r\n" % (arg,)) return 2 args.append(arg) if len(args) > 2: _sys.stderr.write("Too many arguments\n") return 2 elif len(args) < 1: _sys.stderr.write("Missing arguments\n") return 2 basedir = args[0] if len(args) > 1: libdir = args[1] return run_tests(basedir, libdir)