示例#1
0
def main():
    """The entry point to kodi-addon-checker
    """
    load_plugins()
    parser = argparse.ArgumentParser(
        prog="kodi-addon-checker",
        description="Checks Kodi repo for best practices and creates \
                                     problem and warning reports.\r\nIf optional add-on \
                                     directories are provided, check only those add-ons. \
                                     Otherwise, scan current repository and check all add-ons in \
                                     the current directory.")
    parser.add_argument("--version",
                        action="version",
                        version="%(prog)s 0.0.1")
    parser.add_argument("add_on",
                        metavar="add-on",
                        type=dir_type,
                        nargs="*",
                        help="optional add-on directories")
    ConfigManager.fill_cmd_args(parser)
    args = parser.parse_args()

    repo_path = os.path.abspath(os.getcwd())
    config = Config(repo_path, args)
    ConfigManager.process_config(config)
    check_repo(config, repo_path, args.add_on)
示例#2
0
def check_artifact(artifact_path, args, all_repo_addons):
    """
    Check given artifact and return its report. The artifact can be either an add-on or a repository.
    :param artifact_path: the path of add-on or repo
    :param args: argparse object
    :return: report
    """
    logger = logging.getLogger(__package__)
    logger.info("Downloading all repo addon list")
    logger.info("Download completed")
    artifact_path = os.path.abspath(artifact_path)
    config = Config(artifact_path, args)
    ConfigManager.process_config(config)
    if os.path.isfile(os.path.join(artifact_path, "addon.xml")):
        return check_addon.start(artifact_path, args, all_repo_addons, config)
    else:
        return check_repo(artifact_path, args, all_repo_addons, config)
示例#3
0
def main():
    """The entry point to kodi-addon-checker
    """
    load_plugins()
    parser = argparse.ArgumentParser(prog="kodi-addon-checker",
                                     description="Checks Kodi repo for best practices and creates \
                                     problem and warning reports.\r\nIf optional add-on \
                                     directories are provided, check only those add-ons. \
                                     Otherwise, scan current repository and check all add-ons in \
                                     the current directory.")
    parser.add_argument("--version", action="version",
                        version="%(prog)s {version}".format(version=__version__))
    parser.add_argument("dir", type=dir_type, nargs="*", help="optional add-on or repo directories")
    parser.add_argument("--branch", choices=ValidKodiVersions, required=True,
                        help="Target branch name where the checker will resolve dependencies")
    parser.add_argument("--PR", help="Tell if tool is to run on a pull requests or not", action='store_true')
    parser.add_argument("--allow-folder-id-mismatch", help="Allow the addon's folder name and id to mismatch",
                        action="store_true")
    ConfigManager.fill_cmd_args(parser)
    args = parser.parse_args()

    log_file_name = os.path.join(os.getcwd(), "kodi-addon-checker.log")
    Logger.create_logger(log_file_name, __package__)

    all_repo_addons = check_addon.get_all_repo_addons()

    if args.dir:
        # Following report is a wrapper for all sub reports
        report = Report("")
        for directory in args.dir:
            report.add(check_artifact(directory, args, all_repo_addons))
    else:
        report = check_artifact(os.getcwd(), args, all_repo_addons)

    if report.problem_count > 0:
        report.add(Record(PROBLEM, "We found %s problems and %s warnings, please check the logfile." %
                          (report.problem_count, report.warning_count)))
        sys.exit(1)
    elif report.warning_count > 0:
        report.add(Record(WARNING, "We found no problems and %s warnings, please check the logfile." %
                          report.warning_count))
    else:
        report.add(Record(INFORMATION, "We found no problems and no warnings, please enjoy your day."))