Esempio n. 1
0
def main(argv=None):
    argv = argv if argv is not None else sys.argv[1:]

    parser = argparse.ArgumentParser(
        description='Generates metrics from a git repo',
    )
    # optional
    options.add_skip_default_metrics(parser)
    options.add_tempdir_location(parser)
    # positional
    options.add_repo(parser)
    options.add_database(parser)
    options.add_metric_package_names(parser)
    args = parser.parse_args(argv)

    if not os.path.exists(args.database):
        print('Not found: {0}'.format(args.database))
        print('Use git-code-debt-create-tables to create a database.')
        return 1

    load_data(
        args.database,
        args.repo,
        args.metric_package_names,
        args.skip_default_metrics,
        args.tempdir_location,
    )
Esempio n. 2
0
def main(argv=None):
    parser = argparse.ArgumentParser(description='List metric parsers')
    # optional
    options.add_color(parser)
    options.add_skip_default_metrics(parser)
    options.add_metric_package_names(parser)
    args = parser.parse_args(argv)

    color_setting = args.color in ('always', 'auto')

    metric_parsers = get_metric_parsers_from_args(
        args.metric_package_names,
        args.skip_default_metrics,
    )

    metric_parsers_sorted = sorted(
        metric_parsers,
        key=lambda cls: cls.__module__ + cls.__name__
    )

    for metric_parser_cls in metric_parsers_sorted:
        print(
            '{0} {1} {2!r}'.format(
                color(metric_parser_cls.__module__, CYAN, color_setting),
                metric_parser_cls.__name__,
                sorted(metric_parser_cls().get_possible_metric_ids()),
            )
        )
def main(argv=None):
    argv = argv if argv is not None else sys.argv[1:]
    parser = argparse.ArgumentParser(description='List metric parsers')
    # optional
    options.add_color(parser)
    options.add_skip_default_metrics(parser)
    options.add_metric_package_names(parser)
    args = parser.parse_args(argv)

    color_setting = args.color in ('always', 'auto')

    metric_parsers = get_metric_parsers_from_args(
        args.metric_package_names,
        args.skip_default_metrics,
    )

    metric_parsers_sorted = sorted(
        metric_parsers,
        key=lambda cls: cls.__module__ + cls.__name__
    )

    for metric_parser_cls in metric_parsers_sorted:
        print(
            '{0} {1} {2!r}'.format(
                color(metric_parser_cls.__module__, CYAN, color_setting),
                metric_parser_cls.__name__,
                sorted(metric_parser_cls().get_possible_metric_ids()),
            )
        )
Esempio n. 4
0
def get_options_from_argparse(argv):
    parser = argparse.ArgumentParser(
        description='Generates metrics from a git repo', )
    # optional
    options.add_skip_default_metrics(parser)
    # positional
    options.add_repo(parser)
    options.add_database(parser)
    options.add_metric_package_names(parser)
    # These are added here so the help message includes them but are unused
    _add_config_file_options(parser)
    args = parser.parse_args(argv)
    return args
Esempio n. 5
0
def get_options_from_argparse(argv):
    parser = argparse.ArgumentParser(
        description='Generates metrics from a git repo',
    )
    # optional
    options.add_skip_default_metrics(parser)
    # positional
    options.add_repo(parser)
    options.add_database(parser)
    options.add_metric_package_names(parser)
    # These are added here so the help message includes them but are unused
    _add_config_file_options(parser)
    args = parser.parse_args(argv)
    return args
def main(argv=None):
    argv = argv if argv is not None else sys.argv[1:]

    parser = argparse.ArgumentParser(description="Set up schema")
    # optional
    options.add_skip_default_metrics(parser)
    # positional
    options.add_database(parser)
    options.add_metric_package_names(parser)
    args = parser.parse_args(argv)

    with sqlite3.connect(args.database) as db:
        create_schema(db)
        populate_metric_ids(db, args.metric_package_names, args.skip_default_metrics)
Esempio n. 7
0
def main(argv=None):
    parser = argparse.ArgumentParser(description='Set up schema')
    # optional
    options.add_skip_default_metrics(parser)
    # positional
    options.add_database(parser)
    options.add_metric_package_names(parser)
    args = parser.parse_args(argv)

    with sqlite3.connect(args.database) as db:
        create_schema(db)
        populate_metric_ids(
            db,
            args.metric_package_names,
            args.skip_default_metrics,
        )