def main(argv=None): """Command-line entrance to Lizard. Args: argv: Arguments vector; if None, sys.argv by default. """ options = parse_args(argv or sys.argv) printer = options.printer or print_result schema = OutputScheme(options.extensions) if schema.any_silent(): printer = silent_printer schema.patch_for_extensions() if options.input_file: options.paths = auto_read(options.input_file).splitlines() original_stdout = sys.stdout output_file = None if options.output_file: output_file = open_output_file(options.output_file) sys.stdout = output_file result = analyze(options.paths, options.exclude, options.working_threads, options.extensions, options.languages) warning_count = printer(result, options, schema, AllResult) print_extension_results(options.extensions) list(result) if output_file: sys.stdout = original_stdout output_file.close() if 0 <= options.number < warning_count: sys.exit(1)
def main(argv=None): """Command-line entrance to Lizard. Args: argv: Arguments vector; if None, sys.argv by default. """ options = parse_args(argv or sys.argv) printer = options.printer or print_result schema = OutputScheme(options.extensions) if schema.any_silent(): printer = silent_printer schema.patch_for_extensions() if options.input_file: options.paths = auto_read(options.input_file).splitlines() result = analyze( options.paths, options.exclude, options.working_threads, options.extensions, options.languages) warning_count = printer(result, options, schema, AllResult) print_extension_results(options.extensions) list(result) if 0 <= options.number < warning_count: sys.exit(1)
def __call__(self, filename): try: return self.analyze_source_code(filename, auto_read(filename)) except UnicodeDecodeError: sys.stderr.write( "Error: doesn't support none utf encoding '%s'\n" % filename) except IOError: sys.stderr.write("Error: Fail to read source file '%s'\n" % filename) except IndexError: sys.stderr.write("Error: Fail to parse file '%s'\n" % filename) raise return FileInformation(filename, 0, [])
def __call__(self, filename): try: return self.analyze_source_code( filename, auto_read(filename)) except UnicodeDecodeError: sys.stderr.write("Error: doesn't support none utf encoding '%s'\n" % filename) except IOError: sys.stderr.write("Error: Fail to read source file '%s'\n" % filename) except IndexError: sys.stderr.write("Error: Fail to parse file '%s'\n" % filename) raise return FileInformation(filename, 0, [])
def lizard_main(argv): options = parse_args(argv) printer = options.printer or print_result schema = OutputScheme(options.extensions) if schema.any_silent(): printer = silent_printer schema.patch_for_extensions() if options.input_file: options.paths = auto_read(options.input_file).splitlines() result = analyze(options.paths, options.exclude, options.working_threads, options.extensions, options.languages, regression=schema.any_regression()) warning_count = printer(result, options, schema) if options.number < warning_count: sys.exit(1)
def lizard_main(argv): options = parse_args(argv) printer = options.printer or print_result schema = OutputScheme(options.extensions) if schema.any_silent(): printer = silent_printer schema.patch_for_extensions() if options.input_file: options.paths = auto_read(options.input_file).splitlines() result = analyze( options.paths, options.exclude, options.working_threads, options.extensions, options.languages, regression=schema.any_regression()) warning_count = printer(result, options, schema) if options.number < warning_count: sys.exit(1)
def main(argv=None): """Command-line entrance to Lizard. Args: argv: Arguments vector; if None, sys.argv by default. """ options = parse_args(argv or sys.argv) printer = options.printer or print_result schema = OutputScheme(options.extensions) if schema.any_silent(): printer = silent_printer schema.patch_for_extensions() if options.input_file: options.paths = auto_read(options.input_file).splitlines() result = analyze(options.paths, options.exclude, options.working_threads, options.extensions, options.languages, regression=schema.any_regression()) warning_count = printer(result, options, schema) if options.number < warning_count: sys.exit(1)
def test_at(self): result = auto_read( os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data/utf.c')) self.assertIn("after", result)
def test_at(self): result = auto_read(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data/utf.c')) self.assertIn("after", result)