diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:04:05 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:04:05 +0000 |
commit | 676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 (patch) | |
tree | 02a1ac369cb734d0abfa5000dd86e5b7797e6a74 /utils/check_cfc | |
parent | c7e70c433efc6953dc3888b9fbf9f3512d7da2b0 (diff) |
Diffstat (limited to 'utils/check_cfc')
-rwxr-xr-x | utils/check_cfc/check_cfc.py | 15 | ||||
-rwxr-xr-x | utils/check_cfc/obj_diff.py | 8 | ||||
-rw-r--r-- | utils/check_cfc/setup.py | 5 | ||||
-rwxr-xr-x | utils/check_cfc/test_check_cfc.py | 2 |
4 files changed, 17 insertions, 13 deletions
diff --git a/utils/check_cfc/check_cfc.py b/utils/check_cfc/check_cfc.py index 7a739f46e3081..311f502f800b3 100755 --- a/utils/check_cfc/check_cfc.py +++ b/utils/check_cfc/check_cfc.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python """Check CFC - Check Compile Flow Consistency @@ -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 @@ -56,7 +56,10 @@ import shutil import subprocess import sys import tempfile -import ConfigParser +try: + import configparser +except ImportError: + import ConfigParser as configparser import io import obj_diff @@ -95,8 +98,8 @@ def remove_dir_from_path(path_var, directory): PATH""" pathlist = path_var.split(os.pathsep) norm_directory = os.path.normpath(os.path.normcase(directory)) - pathlist = filter(lambda x: os.path.normpath( - os.path.normcase(x)) != norm_directory, pathlist) + pathlist = [x for x in pathlist if os.path.normpath( + os.path.normcase(x)) != norm_directory] return os.pathsep.join(pathlist) def path_without_wrapper(): @@ -318,7 +321,7 @@ if __name__ == '__main__': for c in checks: default_config += "{} = false\n".format(c) - config = ConfigParser.RawConfigParser() + config = configparser.RawConfigParser() config.readfp(io.BytesIO(default_config)) scriptdir = get_main_dir() config_path = os.path.join(scriptdir, 'check_cfc.cfg') diff --git a/utils/check_cfc/obj_diff.py b/utils/check_cfc/obj_diff.py index cc4c2a97d5e5b..a0951c5bcdee4 100755 --- a/utils/check_cfc/obj_diff.py +++ b/utils/check_cfc/obj_diff.py @@ -1,6 +1,6 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python -from __future__ import print_function +from __future__ import absolute_import, division, print_function import argparse import difflib @@ -25,7 +25,7 @@ def disassemble(objfile): if p.returncode or err: print("Disassemble failed: {}".format(objfile)) sys.exit(1) - return filter(keep_line, out.split(os.linesep)) + return [line for line in out.split(os.linesep) if keep_line(line)] def dump_debug(objfile): """Dump all of the debug info from a file.""" @@ -34,7 +34,7 @@ def dump_debug(objfile): if p.returncode or err: print("Dump debug failed: {}".format(objfile)) sys.exit(1) - return filter(keep_line, out.split(os.linesep)) + return [line for line in out.split(os.linesep) if keep_line(line)] def first_diff(a, b, fromfile, tofile): """Returns the first few lines of a difference, if there is one. Python diff --git a/utils/check_cfc/setup.py b/utils/check_cfc/setup.py index b5fc473639ef9..64f07d5dcc52a 100644 --- a/utils/check_cfc/setup.py +++ b/utils/check_cfc/setup.py @@ -1,6 +1,7 @@ """For use on Windows. Run with: python.exe setup.py py2exe """ +from __future__ import absolute_import, division, print_function from distutils.core import setup try: import py2exe @@ -8,10 +9,10 @@ except ImportError: import platform import sys if platform.system() == 'Windows': - print "Could not find py2exe. Please install then run setup.py py2exe." + print("Could not find py2exe. Please install then run setup.py py2exe.") raise else: - print "setup.py only required on Windows." + print("setup.py only required on Windows.") sys.exit(1) setup( diff --git a/utils/check_cfc/test_check_cfc.py b/utils/check_cfc/test_check_cfc.py index e304ff59277d0..0808252a2c60c 100755 --- a/utils/check_cfc/test_check_cfc.py +++ b/utils/check_cfc/test_check_cfc.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2.7 +#!/usr/bin/env python """Test internal functions within check_cfc.py.""" |