#!/usr/bin/env python
"""
Does google-lint on c++ files in a list of directories passed in.
"""
import os
import sys
import cpplint
def unbufferedPrint():
class Unbuffered(object):
def __init__(self, stream):
self.stream = stream
def write(self, data):
self.stream.write(data)
self.stream.flush()
def __getattr__(self, attr):
return getattr(self.stream, attr)
sys.stdout = Unbuffered(sys.stdout)
def process(paths):
''' expects a list of directories to process
'''
cpplint._SetVerboseLevel(0)
failed = False
for path in paths:
print 'Testing', path
for root, dirs, files in os.walk(path):
if '.svn' in dirs:
dirs.remove('.svn')
src = [ os.path.join(root, f) for f in files if f.lower().endswith('.cpp') or f.lower().endswith('.c') or f.lower().endswith('.h') ]
failed = cpplint.process(src) or failed
return failed
if __name__ == '__main__':
unbufferedPrint()
sys.exit(process(sys.argv[1:]))