revert(cmake/Modules/cpplint.py): roll back to python2 version

This reverts commit 65cc4d3c08.
This commit is contained in:
Favonia 2015-01-21 19:36:43 -05:00 committed by Leonardo de Moura
parent 42b5b1e679
commit 51c771f334

View file

@ -76,6 +76,10 @@ We do a small hack, which is to ignore //'s with "'s after them on the
same line, but it is far from perfect (in either direction). same line, but it is far from perfect (in either direction).
""" """
# Python 2/3 compatibility
import six
from six.moves import range, xrange
import codecs import codecs
import copy import copy
import getopt import getopt
@ -668,7 +672,7 @@ class _CppLintState(object):
def PrintErrorCounts(self): def PrintErrorCounts(self):
"""Print a summary of errors by category, and the total.""" """Print a summary of errors by category, and the total."""
for category, count in self.errors_by_category.iteritems(): for category, count in six.iteritems(self.errors_by_category):
sys.stderr.write('Category \'%s\' errors found: %d\n' % sys.stderr.write('Category \'%s\' errors found: %d\n' %
(category, count)) (category, count))
sys.stderr.write('Total errors found: %d\n' % self.error_count) sys.stderr.write('Total errors found: %d\n' % self.error_count)
@ -2837,7 +2841,7 @@ def GetLineWidth(line):
The width of the line in column positions, accounting for Unicode The width of the line in column positions, accounting for Unicode
combining characters and wide characters. combining characters and wide characters.
""" """
if isinstance(line, unicode): if isinstance(line, six.string_types):
width = 0 width = 0
for uc in unicodedata.normalize('NFC', line): for uc in unicodedata.normalize('NFC', line):
if unicodedata.east_asian_width(uc) in ('W', 'F'): if unicodedata.east_asian_width(uc) in ('W', 'F'):
@ -3172,7 +3176,7 @@ def _GetTextInside(text, start_pattern):
# Give opening punctuations to get the matching close-punctuations. # Give opening punctuations to get the matching close-punctuations.
matching_punctuation = {'(': ')', '{': '}', '[': ']'} matching_punctuation = {'(': ')', '{': '}', '[': ']'}
closing_punctuation = set(matching_punctuation.itervalues()) closing_punctuation = set(six.itervalue(matching_punctuation))
# Find the position to start extracting text. # Find the position to start extracting text.
match = re.search(start_pattern, text, re.M) match = re.search(start_pattern, text, re.M)
@ -3796,7 +3800,7 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error,
# include_state is modified during iteration, so we iterate over a copy of # include_state is modified during iteration, so we iterate over a copy of
# the keys. # the keys.
header_keys = include_state.keys() header_keys = list(include_state):
for header in header_keys: for header in header_keys:
(same_module, common_path) = FilesBelongToSameModule(abs_filename, header) (same_module, common_path) = FilesBelongToSameModule(abs_filename, header)
fullpath = common_path + header fullpath = common_path + header