r349504 - Portable Python script across Python version

Serge Guelton via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 18 08:07:37 PST 2018


Author: serge_sans_paille
Date: Tue Dec 18 08:07:37 2018
New Revision: 349504

URL: http://llvm.org/viewvc/llvm-project?rev=349504&view=rev
Log:
Portable Python script across Python version

Make scripts more future-proof by importing most __future__ stuff.

Differential Revision: https://reviews.llvm.org/D55208

Modified:
    cfe/trunk/bindings/python/clang/cindex.py
    cfe/trunk/docs/conf.py
    cfe/trunk/tools/clang-format/clang-format-diff.py
    cfe/trunk/tools/clang-format/clang-format-sublime.py
    cfe/trunk/tools/clang-format/clang-format.py
    cfe/trunk/tools/clang-format/git-clang-format
    cfe/trunk/tools/clang-rename/clang-rename.py
    cfe/trunk/tools/scan-build-py/libscanbuild/arguments.py
    cfe/trunk/utils/ABITest/ABITestGen.py
    cfe/trunk/utils/ABITest/Enumeration.py
    cfe/trunk/utils/CIndex/completion_logger_server.py
    cfe/trunk/utils/TestUtils/deep-stack.py
    cfe/trunk/utils/analyzer/SATestAdd.py
    cfe/trunk/utils/analyzer/SATestUpdateDiffs.py
    cfe/trunk/utils/analyzer/SumTimerInfo.py
    cfe/trunk/utils/check_cfc/check_cfc.py
    cfe/trunk/utils/check_cfc/obj_diff.py
    cfe/trunk/utils/check_cfc/setup.py
    cfe/trunk/utils/clangdiag.py
    cfe/trunk/utils/hmaptool/hmaptool
    cfe/trunk/utils/modfuzz.py
    cfe/trunk/utils/perf-training/perf-helper.py
    cfe/trunk/utils/token-delta.py

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Tue Dec 18 08:07:37 2018
@@ -44,7 +44,7 @@ The major indexing objects are:
 Most object information is exposed using properties, when the underlying API
 call is efficient.
 """
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 # TODO
 # ====

Modified: cfe/trunk/docs/conf.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/conf.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/docs/conf.py (original)
+++ cfe/trunk/docs/conf.py Tue Dec 18 08:07:37 2018
@@ -11,7 +11,7 @@
 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import sys, os
 from datetime import date
 

Modified: cfe/trunk/tools/clang-format/clang-format-diff.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-diff.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/clang-format-diff.py (original)
+++ cfe/trunk/tools/clang-format/clang-format-diff.py Tue Dec 18 08:07:37 2018
@@ -21,7 +21,7 @@ Example usage for git/svn users:
   svn diff --diff-cmd=diff -x-U0 | clang-format-diff.py -i
 
 """
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import argparse
 import difflib

Modified: cfe/trunk/tools/clang-format/clang-format-sublime.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format-sublime.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/clang-format-sublime.py (original)
+++ cfe/trunk/tools/clang-format/clang-format-sublime.py Tue Dec 18 08:07:37 2018
@@ -12,7 +12,7 @@
 # It operates on the current, potentially unsaved buffer and does not create
 # or save any files. To revert a formatting, just undo.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import sublime
 import sublime_plugin
 import subprocess

Modified: cfe/trunk/tools/clang-format/clang-format.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/clang-format.py (original)
+++ cfe/trunk/tools/clang-format/clang-format.py Tue Dec 18 08:07:37 2018
@@ -25,7 +25,7 @@
 #
 # It operates on the current, potentially unsaved buffer and does not create
 # or save any files. To revert a formatting, just undo.
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import difflib
 import json

Modified: cfe/trunk/tools/clang-format/git-clang-format
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/git-clang-format?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/git-clang-format (original)
+++ cfe/trunk/tools/clang-format/git-clang-format Tue Dec 18 08:07:37 2018
@@ -23,7 +23,7 @@ git clang-format -h
 Requires Python 2.7 or Python 3                                                  
 """               
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import argparse
 import collections
 import contextlib

Modified: cfe/trunk/tools/clang-rename/clang-rename.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-rename/clang-rename.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/tools/clang-rename/clang-rename.py (original)
+++ cfe/trunk/tools/clang-rename/clang-rename.py Tue Dec 18 08:07:37 2018
@@ -22,7 +22,7 @@ you would like to rename and press '<lea
 name if the cursor points to a valid symbol.
 '''
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import vim
 import subprocess
 import sys

Modified: cfe/trunk/tools/scan-build-py/libscanbuild/arguments.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build-py/libscanbuild/arguments.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/tools/scan-build-py/libscanbuild/arguments.py (original)
+++ cfe/trunk/tools/scan-build-py/libscanbuild/arguments.py Tue Dec 18 08:07:37 2018
@@ -12,7 +12,7 @@ earlier.)
 It also implements basic validation methods, related to the command.
 Validations are mostly calling specific help methods, or mangling values.
 """
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import os
 import sys

Modified: cfe/trunk/utils/ABITest/ABITestGen.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/ABITestGen.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/utils/ABITest/ABITestGen.py (original)
+++ cfe/trunk/utils/ABITest/ABITestGen.py Tue Dec 18 08:07:37 2018
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from pprint import pprint
 import random, atexit, time
 from random import randrange

Modified: cfe/trunk/utils/ABITest/Enumeration.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ABITest/Enumeration.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/utils/ABITest/Enumeration.py (original)
+++ cfe/trunk/utils/ABITest/Enumeration.py Tue Dec 18 08:07:37 2018
@@ -1,6 +1,6 @@
 """Utilities for enumeration of finite and countably infinite sets.
 """
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 ###
 # Countable iteration
 

Modified: cfe/trunk/utils/CIndex/completion_logger_server.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/CIndex/completion_logger_server.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/utils/CIndex/completion_logger_server.py (original)
+++ cfe/trunk/utils/CIndex/completion_logger_server.py Tue Dec 18 08:07:37 2018
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import sys
 from socket import *
 from time import strftime

Modified: cfe/trunk/utils/TestUtils/deep-stack.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TestUtils/deep-stack.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/utils/TestUtils/deep-stack.py (original)
+++ cfe/trunk/utils/TestUtils/deep-stack.py Tue Dec 18 08:07:37 2018
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 def pcall(f, N):
     if N == 0:
         print('    f(0)', file=f)

Modified: cfe/trunk/utils/analyzer/SATestAdd.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestAdd.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/utils/analyzer/SATestAdd.py (original)
+++ cfe/trunk/utils/analyzer/SATestAdd.py Tue Dec 18 08:07:37 2018
@@ -42,7 +42,7 @@ the Repository Directory.
                                           diff -ur CachedSource PatchedSource \
                                               > changes_for_analyzer.patch
 """
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import SATestBuild
 
 import os

Modified: cfe/trunk/utils/analyzer/SATestUpdateDiffs.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SATestUpdateDiffs.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/utils/analyzer/SATestUpdateDiffs.py (original)
+++ cfe/trunk/utils/analyzer/SATestUpdateDiffs.py Tue Dec 18 08:07:37 2018
@@ -3,7 +3,7 @@
 """
 Update reference results for static analyzer.
 """
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import SATestBuild
 

Modified: cfe/trunk/utils/analyzer/SumTimerInfo.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/SumTimerInfo.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/utils/analyzer/SumTimerInfo.py (original)
+++ cfe/trunk/utils/analyzer/SumTimerInfo.py Tue Dec 18 08:07:37 2018
@@ -6,7 +6,7 @@ Script to Summarize statistics in the sc
 Statistics are enabled by passing '-internal-stats' option to scan-build
 (or '-analyzer-stats' to the analyzer).
 """
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import sys
 

Modified: cfe/trunk/utils/check_cfc/check_cfc.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/check_cfc/check_cfc.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/utils/check_cfc/check_cfc.py (original)
+++ cfe/trunk/utils/check_cfc/check_cfc.py Tue Dec 18 08:07:37 2018
@@ -47,7 +47,7 @@ To add a new check:
  subclass.
 """
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import imp
 import os

Modified: cfe/trunk/utils/check_cfc/obj_diff.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/check_cfc/obj_diff.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/utils/check_cfc/obj_diff.py (original)
+++ cfe/trunk/utils/check_cfc/obj_diff.py Tue Dec 18 08:07:37 2018
@@ -1,6 +1,6 @@
 #!/usr/bin/env python2.7
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import argparse
 import difflib

Modified: cfe/trunk/utils/check_cfc/setup.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/check_cfc/setup.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/utils/check_cfc/setup.py (original)
+++ cfe/trunk/utils/check_cfc/setup.py Tue Dec 18 08:07:37 2018
@@ -1,7 +1,7 @@
 """For use on Windows. Run with:
     python.exe setup.py py2exe
     """
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from distutils.core import setup
 try:
     import py2exe

Modified: cfe/trunk/utils/clangdiag.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/clangdiag.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/utils/clangdiag.py (original)
+++ cfe/trunk/utils/clangdiag.py Tue Dec 18 08:07:37 2018
@@ -9,7 +9,7 @@
 #   (lldb) command script import /path/to/clandiag.py
 #----------------------------------------------------------------------
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import lldb
 import argparse
 import shlex

Modified: cfe/trunk/utils/hmaptool/hmaptool
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/hmaptool/hmaptool?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/utils/hmaptool/hmaptool (original)
+++ cfe/trunk/utils/hmaptool/hmaptool Tue Dec 18 08:07:37 2018
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import json
 import optparse

Modified: cfe/trunk/utils/modfuzz.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/modfuzz.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/utils/modfuzz.py (original)
+++ cfe/trunk/utils/modfuzz.py Tue Dec 18 08:07:37 2018
@@ -4,7 +4,7 @@
 #  1) Update the 'decls' list below with your fuzzing configuration.
 #  2) Run with the clang binary as the command-line argument.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import random
 import subprocess
 import sys

Modified: cfe/trunk/utils/perf-training/perf-helper.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/perf-helper.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/utils/perf-training/perf-helper.py (original)
+++ cfe/trunk/utils/perf-training/perf-helper.py Tue Dec 18 08:07:37 2018
@@ -7,7 +7,7 @@
 #
 #===------------------------------------------------------------------------===#
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import sys
 import os

Modified: cfe/trunk/utils/token-delta.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/token-delta.py?rev=349504&r1=349503&r2=349504&view=diff
==============================================================================
--- cfe/trunk/utils/token-delta.py (original)
+++ cfe/trunk/utils/token-delta.py Tue Dec 18 08:07:37 2018
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import os
 import re
 import subprocess




More information about the cfe-commits mailing list