mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 09:46:02 -04:00
Merge pull request #120 from vbraun/cpplint-py3
Make cpplint.py Python-3 compatible
This commit is contained in:
commit
d390342be7
22
cpplint.py
vendored
22
cpplint.py
vendored
@ -53,6 +53,15 @@ import sys
|
|||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
xrange(0,1)
|
||||||
|
PY3 = False
|
||||||
|
except NameError:
|
||||||
|
PY3 = True # Python 3
|
||||||
|
xrange = range
|
||||||
|
unicode = str
|
||||||
|
|
||||||
|
|
||||||
_USAGE = """
|
_USAGE = """
|
||||||
Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
|
Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...]
|
||||||
[--counting=total|toplevel|detailed] [--root=subdir]
|
[--counting=total|toplevel|detailed] [--root=subdir]
|
||||||
@ -736,7 +745,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."""
|
||||||
# SRombauts: "cpplint:" prefix
|
# SRombauts: "cpplint:" prefix
|
||||||
for category, count in self.errors_by_category.iteritems():
|
for category, count in self.errors_by_category.items():
|
||||||
sys.stderr.write('cpplint: Category \'%s\' errors found: %d\n' %
|
sys.stderr.write('cpplint: Category \'%s\' errors found: %d\n' %
|
||||||
(category, count))
|
(category, count))
|
||||||
# SRombauts: "cpplint:" prefix and error message only when appropriate
|
# SRombauts: "cpplint:" prefix and error message only when appropriate
|
||||||
@ -3694,7 +3703,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(matching_punctuation.values())
|
||||||
|
|
||||||
# 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)
|
||||||
@ -4779,10 +4788,11 @@ def main():
|
|||||||
|
|
||||||
# Change stderr to write with replacement characters so we don't die
|
# Change stderr to write with replacement characters so we don't die
|
||||||
# if we try to print something containing non-ASCII characters.
|
# if we try to print something containing non-ASCII characters.
|
||||||
sys.stderr = codecs.StreamReaderWriter(sys.stderr,
|
if not PY3:
|
||||||
codecs.getreader('utf8'),
|
sys.stderr = codecs.StreamReaderWriter(sys.stderr,
|
||||||
codecs.getwriter('utf8'),
|
codecs.getreader('utf8'),
|
||||||
'replace')
|
codecs.getwriter('utf8'),
|
||||||
|
'replace')
|
||||||
|
|
||||||
_cpplint_state.ResetErrorCounts()
|
_cpplint_state.ResetErrorCounts()
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user