From d3637f0286916681d5d1229e1ed2e8edabe313fb Mon Sep 17 00:00:00 2001 From: Bas Date: Thu, 25 Apr 2024 20:32:46 +0200 Subject: [PATCH] Added: Reject add-ons targeting Python 2. --- kodi_addon_checker/check_addon.py | 4 +++- kodi_addon_checker/check_dependencies.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/kodi_addon_checker/check_addon.py b/kodi_addon_checker/check_addon.py index 62bded4..8c753fa 100644 --- a/kodi_addon_checker/check_addon.py +++ b/kodi_addon_checker/check_addon.py @@ -54,7 +54,9 @@ def start(addon_path, args, all_repo_addons, config=None): addon_xml = check_files.check_addon_xml(addon_report, addon_path, parsed_xml, args.allow_folder_id_mismatch) if addon_xml is not None: - check_addon_branches.check_for_existing_addon(addon_report, Addon(parsed_xml), all_repo_addons, args) + addon = Addon(parsed_xml) + check_dependencies.check_python_dependency(addon_report, addon) + check_addon_branches.check_for_existing_addon(addon_report, addon, all_repo_addons, args) if not addon_xml.findall("*//broken") and \ not (addon_xml.findall("*//lifecyclestate") and \ diff --git a/kodi_addon_checker/check_dependencies.py b/kodi_addon_checker/check_dependencies.py index 39df7b9..88c6543 100644 --- a/kodi_addon_checker/check_dependencies.py +++ b/kodi_addon_checker/check_dependencies.py @@ -116,6 +116,19 @@ LOGGER = logging.getLogger(__name__) +def check_python_dependency(report: Report, addon: Addon): + """ Checks if the Python dependency targets version 3 or highter. + + :report: the report object + :addon: the Addon object (contains id and version) + """ + + for dependency in addon.dependencies: + if dependency.id == 'xbmc.python' and dependency.version < AddonVersion("3.0.0"): + report.add(Record(PROBLEM, "Add-ons should target Python 3 and up.")) + return + + def check_addon_dependencies(report: Report, repo_addons: dict, parsed_xml, args): """Check for any new dependencies in addon.xml file and reports them :parsed_xml: parsed addon.xml file