コード例 #1
0
def start(addon_path, repo_addons, config=None):
    addon_id = os.path.basename(os.path.normpath(addon_path))
    addon_report = Report(addon_id)
    addon_report.add(Record(INFORMATION, "Checking add-on %s" % addon_id))

    global REL_PATH
    # Extract common path from addon paths
    # All paths will be printed relative to this path
    REL_PATH = os.path.split(addon_path[:-1])[0]
    addon_xml = _check_addon_xml(addon_report, addon_path)

    if addon_xml is not None:
        if len(addon_xml.findall("*//broken")) == 0:
            file_index = _create_file_index(addon_path)

            _check_dependencies(addon_report, addon_path, repo_addons)

            _check_for_invalid_xml_files(addon_report, file_index)

            _check_for_invalid_json_files(addon_report, file_index)

            _check_artwork(addon_report, addon_path, addon_xml, file_index)

            max_entrypoint_line_count = config.configs.get(
                "max_entrypoint_line_count", 15)
            _check_complex_addon_entrypoint(addon_report, addon_path,
                                            max_entrypoint_line_count)

            if config.is_enabled("check_license_file_exists"):
                # check if license file is existing
                _addon_file_exists(addon_report, addon_path,
                                   r"^LICENSE\.txt|LICENSE\.md|LICENSE$")

            if config.is_enabled("check_legacy_strings_xml"):
                _check_for_legacy_strings_xml(addon_report, addon_path)

            if config.is_enabled("check_legacy_language_path"):
                _check_for_legacy_language_path(addon_report, addon_path)

            # Kodi 18 Leia + deprecations
            if config.is_enabled("check_kodi_leia_deprecations"):
                _find_blacklisted_strings(addon_report, addon_path, [
                    "System.HasModalDialog", "StringCompare", "SubString",
                    "IntegerGreaterThan", "ListItem.ChannelNumber",
                    "ListItem.SubChannelNumber", "MusicPlayer.ChannelNumber",
                    "MusicPlayer.SubChannelNumber",
                    "VideoPlayer.ChannelNumber", "VideoPlayer.SubChannelNumber"
                ], [], [".py", ".xml"])

            # General blacklist
            _find_blacklisted_strings(addon_report, addon_path, [], [], [])

            _check_file_whitelist(addon_report, file_index, addon_path)
        else:
            addon_report.add(
                Record(INFORMATION, "Addon marked as broken - skipping"))

    return addon_report
コード例 #2
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."))
コード例 #3
0
def check_repo(config, repo_path, parameters):
    repo_report = Report(repo_path)
    repo_report.add(Record(INFORMATION, "Checking repository %s" % repo_path))
    if len(parameters) == 0:
        toplevel_folders = sorted(next(os.walk(repo_path))[1])
    else:
        toplevel_folders = sorted(parameters)

    for addon_folder in toplevel_folders:
        if addon_folder[0] != '.':
            repo_report.add(
                Record(INFORMATION, "Checking add-on %s" % addon_folder))
            addon_path = os.path.join(repo_path, addon_folder)
            addon_report = check_addon.start(addon_path, config)
            repo_report.add(addon_report)

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

    ReportManager.report(repo_report)
コード例 #4
0
 def setUp(self):
     self.path = join(HERE, "test_data", "PO_files")
     load_plugins()
     ReportManager.enable(["array"])
     self.report = Report("")
     self.report_matches = ("ERROR: Invalid PO file")
コード例 #5
0
 def setUp(self):
     load_plugins()
     ReportManager.enable(["array"])
     self.report = Report("")