diff options
Diffstat (limited to 'Tools/scripts/patchcheck.py')
-rwxr-xr-x | Tools/scripts/patchcheck.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/Tools/scripts/patchcheck.py b/Tools/scripts/patchcheck.py index 438e44eeff8..0e18dd9356d 100755 --- a/Tools/scripts/patchcheck.py +++ b/Tools/scripts/patchcheck.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import re import sys import shutil @@ -26,11 +26,11 @@ def status(message, modal=False, info=None): sys.stdout.flush() result = fxn(*args, **kwargs) if not modal and not info: - print "done" + print("done") elif info: - print info(result) + print(info(result)) else: - print "yes" if result else "NO" + print("yes" if result else "NO") return result return call_fxn return decorated_fxn @@ -39,15 +39,11 @@ def status(message, modal=False, info=None): def mq_patches_applied(): """Check if there are any applied MQ patches.""" cmd = 'hg qapplied' - st = subprocess.Popen(cmd.split(), + with subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - try: + stderr=subprocess.PIPE) as st: bstdout, _ = st.communicate() return st.returncode == 0 and bstdout - finally: - st.stdout.close() - st.stderr.close() @status("Getting the list of files that have been added/changed", @@ -72,7 +68,7 @@ def changed_files(): return [x.decode().rstrip() for x in st.stdout] else: output = (x.decode().rstrip().rsplit(None, 1)[-1] - for x in st.stdout if x[0] in 'AM') + for x in st.stdout if x[0] in b'AM') return set(path for path in output if os.path.isfile(path)) finally: st.stdout.close() @@ -131,7 +127,7 @@ def normalize_docs_whitespace(file_paths): f.writelines(new_lines) fixed.append(path) except Exception as err: - print 'Cannot fix %s: %s' % (path, err) + print('Cannot fix %s: %s' % (path, err)) return fixed @@ -174,8 +170,8 @@ def main(): # Test suite run and passed. if python_files or c_files: - print - print "Did you run the test suite?" + print() + print("Did you run the test suite?") if __name__ == '__main__': |