Skip to content

Commit

Permalink
Add check for print statement
Browse files Browse the repository at this point in the history
  • Loading branch information
mzfr committed Jan 19, 2019
1 parent 76377d9 commit b8e49e4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions kodi_addon_checker/check_addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def start(addon_path, branch_name, all_repo_addons, pr, config=None):

check_dependencies.check_reverse_dependencies(addon_report, addon_id, branch_name, all_repo_addons)

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)
Expand Down
16 changes: 16 additions & 0 deletions kodi_addon_checker/check_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
pattern = "^print([\s\S]*)"
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 re.match(pattern, line):
report.add(Record(WARNING, "%s have print statement on line number %s" %
(relative_path(str(file)), ind)))

0 comments on commit b8e49e4

Please sign in to comment.