コード例 #1
0
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)
コード例 #2
0
ファイル: lizard.py プロジェクト: terryyin/lizard
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)
コード例 #3
0
ファイル: lizard.py プロジェクト: Guansz/codeccScan
 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, [])
コード例 #4
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, [])
コード例 #5
0
ファイル: lizard.py プロジェクト: mehrdad89/lizard
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)
コード例 #6
0
ファイル: lizard.py プロジェクト: serjant/lizard
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)
コード例 #7
0
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)
コード例 #8
0
ファイル: test_auto_open.py プロジェクト: wangliyao518/lizard
 def test_at(self):
     result = auto_read(
         os.path.join(os.path.dirname(os.path.realpath(__file__)),
                      'data/utf.c'))
     self.assertIn("after", result)
コード例 #9
0
ファイル: test_auto_open.py プロジェクト: incnb/lizard
 def test_at(self):
     result = auto_read(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'data/utf.c'))
     self.assertIn("after", result)