Skip to content

Commit

Permalink
[fix] 2to3: interpret print as function
Browse files Browse the repository at this point in the history
if it fails, fallback to print statement
  • Loading branch information
Rechi committed Apr 12, 2019
1 parent fe9cb5a commit 7f1766c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions kodi_addon_checker/check_py3_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ def check_py3_compatibility(report: Report, path: str, branch_name: str):

fixer_names = ['lib2to3.fixes.fix_' + fix for fix in list_of_fixes]

rt = KodiRefactoringTool(report, PROBLEM, fixer_names, options=None, explicit=None)
rt = KodiRefactoringTool(report, PROBLEM, fixer_names, options={"print_function": True}, explicit=None)
try:
rt.refactor([path])
except pgen2.parse.ParseError as e:
report.add(Record(PROBLEM, "ParseError: {}".format(e)))
rt = KodiRefactoringTool(report, PROBLEM, fixer_names, options=None, explicit=None)
try:
rt.refactor([path])
except pgen2.parse.ParseError as e:
report.add(Record(PROBLEM, "ParseError: {}".format(e)))

if branch_name not in ['gotham', 'helix', 'isengard', 'jarvis']:
list_of_fixes = [
Expand All @@ -85,8 +89,12 @@ def check_py3_compatibility(report: Report, path: str, branch_name: str):

fixer_names = ['lib2to3.fixes.fix_' + fix for fix in list_of_fixes]

rt = KodiRefactoringTool(report, INFORMATION, fixer_names, options=None, explicit=None)
rt = KodiRefactoringTool(report, INFORMATION, fixer_names, options={"print_function": True}, explicit=None)
try:
rt.refactor([path])
except pgen2.parse.ParseError as e:
report.add(Record(INFORMATION, "ParseError: {}".format(e)))
rt = KodiRefactoringTool(report, INFORMATION, fixer_names, options=None, explicit=None)
try:
rt.refactor([path])
except pgen2.parse.ParseError as e:
report.add(Record(INFORMATION, "ParseError: {}".format(e)))

0 comments on commit 7f1766c

Please sign in to comment.