From 997e6a7910fcdcfcb74f4e3762b843f654291a67 Mon Sep 17 00:00:00 2001 From: nanahpang <31627465+nanahpang@users.noreply.github.com> Date: Mon, 3 Aug 2020 12:20:56 -0700 Subject: [PATCH] Update check_include_guards.py Fixed the Py3 checker issue during import. Use print() instead of print and add "from __future__ import print_function" for py2 and py3 compatibility. --- tools/distrib/check_include_guards.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/distrib/check_include_guards.py b/tools/distrib/check_include_guards.py index 21a90383589..8a76b2b0d9f 100755 --- a/tools/distrib/check_include_guards.py +++ b/tools/distrib/check_include_guards.py @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import print_function import argparse import os import os.path @@ -62,22 +63,22 @@ class GuardValidator(object): '...\n') + ('#endif /* {2} */' if c_core_header else '#endif // {2}') if not match_txt: - print invalid_guards_msg_template.format(fpath, regexp.pattern, - build_valid_guard(fpath)) + print(invalid_guards_msg_template.format(fpath, regexp.pattern, + build_valid_guard(fpath))) return fcontents - print( + print(( '{}: Wrong preprocessor guards (RE {}):' '\n\tFound {}, expected {}').format(fpath, regexp.pattern, - match_txt, correct) + match_txt, correct)) if fix: - print 'Fixing {}...\n'.format(fpath) + print('Fixing {}...\n'.format(fpath)) fixed_fcontents = re.sub(match_txt, correct, fcontents) if fixed_fcontents: self.failed = False return fixed_fcontents else: - print + print() return fcontents def check(self, fpath, fix): @@ -89,7 +90,7 @@ class GuardValidator(object): match = self.ifndef_re.search(fcontents) if not match: - print 'something drastically wrong with: %s' % fpath + print('something drastically wrong with: %s' % fpath) return False # failed if match.lastindex is None: # No ifndef. Request manual addition with hints