Beispiel #1
0
 def test_print_relevant_bears(self):
     with retrieve_stdout() as custom_stdout:
         print_relevant_bears(
             self.printer,
             filter_relevant_bears([('Python', 70), ('Unknown', 30)],
                                   self.printer, self.arg_parser, {}))
         self.assertIn("PycodestyleBear", custom_stdout.getvalue())
def main():
    arg_parser = _get_arg_parser()
    args = arg_parser.parse_args()

    printer = ConsolePrinter()
    log_printer = LogPrinter(printer)

    project_dir = os.getcwd()
    if not args.non_interactive:
        print_welcome_message(printer)
        project_dir = ask_question("What is your project directory?",
                                   default=project_dir,
                                   typecast=valid_path)

    project_files, ignore_globs = get_project_files(log_printer, printer,
                                                    project_dir)

    used_languages = list(get_used_languages(project_files))
    print_used_languages(printer, used_languages)

    relevant_bears = filter_relevant_bears(used_languages, arg_parser)
    print_relevant_bears(printer, relevant_bears)

    if args.non_interactive:
        unusable_bears = get_non_optional_settings_bears(relevant_bears)
        remove_unusable_bears(relevant_bears, unusable_bears)
        print_relevant_bears(printer, relevant_bears, 'usable')

    settings = generate_settings(project_dir, project_files, ignore_globs,
                                 relevant_bears)
    write_coafile(printer, project_dir, settings)
Beispiel #3
0
def main():
    arg_parser = _get_arg_parser()
    args = arg_parser.parse_args()

    logging.basicConfig(stream=sys.stdout)
    printer = ConsolePrinter()
    logging.getLogger(__name__)

    fpc = None
    project_dir = os.getcwd()

    if args.green_mode:
        args.non_interactive = None
        args.no_filter_by_capabilities = None
        args.incomplete_sections = None

    if not args.non_interactive and not args.green_mode:
        fpc = FilePathCompleter()
        fpc.activate()
        print_welcome_message(printer)
        printer.print(PROJECT_DIR_HELP)
        project_dir = ask_question('What is your project directory?',
                                   default=project_dir,
                                   typecast=valid_path)
        fpc.deactivate()

    project_files, ignore_globs = get_project_files(None, printer, project_dir,
                                                    fpc, args.non_interactive)

    used_languages = list(get_used_languages(project_files))
    print_used_languages(printer, used_languages)

    extracted_information = collect_info(project_dir)

    relevant_bears = filter_relevant_bears(used_languages, printer, arg_parser,
                                           extracted_information)

    if args.green_mode:
        collect_bear_settings(relevant_bears)

    print_relevant_bears(printer, relevant_bears)

    if args.non_interactive and not args.incomplete_sections:
        unusable_bears = get_non_optional_settings_bears(relevant_bears)
        remove_unusable_bears(relevant_bears, unusable_bears)
        print_relevant_bears(printer, relevant_bears, 'usable')

    settings = generate_settings(project_dir, project_files, ignore_globs,
                                 relevant_bears, extracted_information,
                                 args.incomplete_sections)

    write_coafile(printer, project_dir, settings)
Beispiel #4
0
def main():
    printer = ConsolePrinter()
    log_printer = LogPrinter(printer)

    print_welcome_message(printer)

    project_dir = ask_question("What is your project directory?",
                               default=os.getcwd(),
                               typecast=valid_path)
    project_files, ignore_globs = get_project_files(log_printer, printer,
                                                    project_dir)

    used_languages = list(get_used_languages(project_files))
    print_used_languages(printer, used_languages)

    relevant_bears = filter_relevant_bears(used_languages)
    print_relevant_bears(printer, relevant_bears)

    settings = generate_settings(project_dir, project_files, ignore_globs,
                                 relevant_bears)
    write_coafile(printer, project_dir, settings)
def main():
    global MAX_ARGS_GREEN_MODE, MAX_VALUES_GREEN_MODE
    arg_parser = _get_arg_parser()
    args = arg_parser.parse_args()

    logging.basicConfig(stream=sys.stdout)
    printer = ConsolePrinter()
    logging.getLogger(__name__)

    fpc = None
    project_dir = os.getcwd()

    if args.green_mode:
        args.no_filter_by_capabilities = None
        args.incomplete_sections = None
        if args.max_args:
            MAX_ARGS_GREEN_MODE = args.max_args
        if args.max_values:
            MAX_VALUES_GREEN_MODE = args.max_values

    if not args.green_mode and (args.max_args or args.max_values):
        logging.warning(' --max-args and --max-values can be used '
                        'only with --green-mode. The arguments will '
                        'be ignored.')

    if not args.non_interactive and not args.green_mode:
        fpc = FilePathCompleter()
        fpc.activate()
        print_welcome_message(printer)
        printer.print(PROJECT_DIR_HELP)
        project_dir = ask_question(
            'What is your project directory?',
            default=project_dir,
            typecast=valid_path)
        fpc.deactivate()

    project_files, ignore_globs = get_project_files(
        None,
        printer,
        project_dir,
        fpc,
        args.non_interactive)

    used_languages = list(get_used_languages(project_files))
    used_languages = ask_to_select_languages(used_languages, printer,
                                             args.non_interactive)

    extracted_information = collect_info(project_dir)

    relevant_bears = filter_relevant_bears(
        used_languages, printer, arg_parser, extracted_information)

    if args.green_mode:
        bear_settings_obj = collect_bear_settings(relevant_bears)
        green_mode(
            project_dir, ignore_globs, relevant_bears, bear_settings_obj,
            MAX_ARGS_GREEN_MODE,
            MAX_VALUES_GREEN_MODE,
            project_files,
            printer,
        )
        exit()

    print_relevant_bears(printer, relevant_bears)

    if args.non_interactive and not args.incomplete_sections:
        unusable_bears = get_non_optional_settings_bears(relevant_bears)
        remove_unusable_bears(relevant_bears, unusable_bears)
        print_relevant_bears(printer, relevant_bears, 'usable')

    settings = generate_settings(
        project_dir,
        project_files,
        ignore_globs,
        relevant_bears,
        extracted_information,
        args.incomplete_sections)

    write_coafile(printer, project_dir, settings)
Beispiel #6
0
def main():
    global MAX_ARGS_GREEN_MODE, MAX_VALUES_GREEN_MODE
    arg_parser = _get_arg_parser()
    args = arg_parser.parse_args()

    logging.basicConfig(stream=sys.stdout)
    printer = ConsolePrinter()
    logging.getLogger(__name__)

    fpc = None
    project_dir = os.getcwd()

    if args.green_mode:
        args.no_filter_by_capabilities = None
        args.incomplete_sections = None
        if args.max_args:
            MAX_ARGS_GREEN_MODE = args.max_args
        if args.max_values:
            MAX_VALUES_GREEN_MODE = args.max_values

    if not args.green_mode and (args.max_args or args.max_values):
        logging.warning(' --max-args and --max-values can be used '
                        'only with --green-mode. The arguments will '
                        'be ignored.')

    if not args.non_interactive and not args.green_mode:
        fpc = FilePathCompleter()
        fpc.activate()
        print_welcome_message(printer)
        printer.print(PROJECT_DIR_HELP)
        project_dir = ask_question('What is your project directory?',
                                   default=project_dir,
                                   typecast=valid_path)
        fpc.deactivate()

    project_files, ignore_globs = get_project_files(None, printer, project_dir,
                                                    fpc, args.non_interactive)

    used_languages = list(get_used_languages(project_files))
    used_languages = ask_to_select_languages(used_languages, printer,
                                             args.non_interactive)

    extracted_information = collect_info(project_dir)

    relevant_bears = filter_relevant_bears(used_languages, printer, arg_parser,
                                           extracted_information)

    if args.green_mode:
        bear_settings_obj = collect_bear_settings(relevant_bears)
        green_mode(
            project_dir,
            ignore_globs,
            relevant_bears,
            bear_settings_obj,
            MAX_ARGS_GREEN_MODE,
            MAX_VALUES_GREEN_MODE,
            project_files,
            printer,
        )
        exit()

    print_relevant_bears(printer, relevant_bears)

    if args.non_interactive and not args.incomplete_sections:
        unusable_bears = get_non_optional_settings_bears(relevant_bears)
        remove_unusable_bears(relevant_bears, unusable_bears)
        print_relevant_bears(printer, relevant_bears, 'usable')

    settings = generate_settings(project_dir, project_files, ignore_globs,
                                 relevant_bears, extracted_information,
                                 args.incomplete_sections)

    write_coafile(printer, project_dir, settings)
 def test_print_relevant_bears(self):
     with retrieve_stdout() as custom_stdout:
         print_relevant_bears(self.printer, filter_relevant_bears(
             [('Python', 70), ('Unknown', 30)], self.printer,
             self.arg_parser, {}))
         self.assertIn("PycodestyleBear", custom_stdout.getvalue())