def main():
    """Entry point for this script."""

    parser, args = parse_command_line_arguments()
    logger = initialize_logging(args.debug, args.less_verbose)

    result = 0

    if args.download:
        try:
            download_listing(args.listing)
        except DownloadRetfListingFailed as ex:
            logger.error("Downloading latest RETF listing failed: %s.", ex)
            result = 1

    if not args.path and not args.file and not args.download:
        parser.print_help()
        result = 2

    if not result and not os.path.isfile(args.listing):
        logger.error("RETF listing not found at %s.", args.listing)
        logger.info("Please download the RETF listing first by using the "
                    "parameter --download.")
        result = 1

    if not result:
        files = get_file_listing(args.path, args.file, args.extension)

        rules = generate_listing(args.listing)
        disabled = load_disabled_rules(args.disabled)

        all_findings = 0
        for check in files:
            if not os.path.isfile(check):
                continue

            (findings, content) = check_file(check, rules, disabled)

            if findings > 0:
                all_findings += findings
                logger.warning("%s finding(s) in file %s.", findings, check)

            if findings > 0 and args.write_changes:
                write_text_to_file(check, content, args.no_backup,
                                   args.in_place)

        if all_findings > 0:
            logger.warning("%s finding(s) in all checked files.", all_findings)
            result = 1

    return result
dataset/ETHPy150Open openstack/openstack-doc-tools/cleanup/retf/retf.py/main/original