1#!/usr/local/bin/python 2# 3# 4# Licensed to the Apache Software Foundation (ASF) under one 5# or more contributor license agreements. See the NOTICE file 6# distributed with this work for additional information 7# regarding copyright ownership. The ASF licenses this file 8# to you under the Apache License, Version 2.0 (the 9# "License"); you may not use this file except in compliance 10# with the License. You may obtain a copy of the License at 11# 12# http://www.apache.org/licenses/LICENSE-2.0 13# 14# Unless required by applicable law or agreed to in writing, 15# software distributed under the License is distributed on an 16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17# KIND, either express or implied. See the License for the 18# specific language governing permissions and limitations 19# under the License. 20# 21# 22# 23# Find places in our code where whitespace is erroneously used before 24# the open-paren on a function all. This is typically manifested like: 25# 26# return svn_some_function 27# (param1, param2, param3) 28# 29# 30# USAGE: find-bad-style.py FILE1 FILE2 ... 31# 32 33import sys 34import re 35 36re_call = re.compile(r'^\s*\(') 37re_func = re.compile(r'.*[a-z0-9_]{1,}\s*$') 38 39 40def scan_file(fname): 41 lines = open(fname).readlines() 42 43 prev = None 44 line_num = 1 45 46 for line in lines: 47 if re_call.match(line): 48 if prev and re_func.match(prev): 49 print('%s:%d:%s' % (fname, line_num - 1, prev.rstrip())) 50 51 prev = line 52 line_num += 1 53 54 55if __name__ == '__main__': 56 for fname in sys.argv[1:]: 57 scan_file(fname) 58