21 os.chdir(os.path.join(os.path.dirname(sys.argv[0]),
'../../..'))
24 (
r'\n#include "include/(.*)"',
r'\n#include <\1>'),
25 (
r'\n#include "grpc(.*)"',
r'\n#include <grpc\1>'),
28 fix = sys.argv[1:] == [
'--fix']
35 for root, dirs, files
in os.walk(directory_root):
36 for filename
in files:
37 path = os.path.join(root, filename)
38 if os.path.splitext(path)[1]
not in [
'.c',
'.cc',
'.h']:
40 if filename.endswith(
'.pb.h')
or filename.endswith(
'.pb.c'):
43 if (filename.endswith(
'.upb.h')
or filename.endswith(
'.upb.c')
or
44 filename.endswith(
'.upbdefs.h')
or
45 filename.endswith(
'.upbdefs.c')):
50 for regex, replace
in BAD_REGEXES:
51 text = re.sub(regex, replace, text)
53 bad_files.append(path)
55 with open(path,
'w')
as f:
69 for f
in all_bad_files:
70 print(
"%s has badly formed grpc system header files" % f)