diff --git a/kodi_addon_checker/check_addon.py b/kodi_addon_checker/check_addon.py index ef04215d..ca67cf90 100644 --- a/kodi_addon_checker/check_addon.py +++ b/kodi_addon_checker/check_addon.py @@ -55,6 +55,8 @@ def start(addon_path, branch_name, all_repo_addons, pr, config=None): check_dependencies.check_addon_dependencies(addon_report, repo_addons, parsed_xml, branch_name) + check_files.check_print_statement(addon_report, file_index) + check_files.check_file_permission(addon_report, file_index) check_files.check_for_invalid_xml_files(addon_report, file_index) diff --git a/kodi_addon_checker/check_files.py b/kodi_addon_checker/check_files.py index 809e63b8..7d634863 100644 --- a/kodi_addon_checker/check_files.py +++ b/kodi_addon_checker/check_files.py @@ -131,3 +131,19 @@ def check_file_permission(report: Report, file_index: list): file = os.path.join(file["path"], file["name"]) if os.path.isfile(file) and os.access(str(file), os.X_OK): report.add(Record(PROBLEM, "%s is marked as stand-alone executable" % relative_path(str(file)))) + + +def check_print_statement(report: Report, file_index: list): + """Check whether any addon files have a print statement in them + or not + :file_index: list having names and path of all the files present in addon + """ + + for file in file_index: + if os.path.splitext(file["name"])[1] == '.py': + file = os.path.join(file["path"], file["name"]) + with open(file, 'r') as f: + for ind, line in enumerate(f, 1): + if 'print(' in line or 'print (' in line: + report.add(Record(WARNING, "%s have print statement on line number %s" % + (relative_path(str(file)), ind)))