Lines Matching refs:fpath
25 def build_valid_guard(fpath): argument
26 prefix = 'GRPC_' if not fpath.startswith('include/') else ''
28 fpath.replace('++', 'XX').replace('.', '_').upper().split('/')[1:])
31 def load(fpath): argument
32 with open(fpath, 'r') as f:
36 def save(fpath, contents): argument
37 with open(fpath, 'w') as f:
51 def fail(self, fpath, regexp, fcontents, match_txt, correct, fix): argument
52 cpp_header = 'grpc++' in fpath or 'grpcpp' in fpath
63 print invalid_guards_msg_template.format(fpath, regexp.pattern,
64 build_valid_guard(fpath))
68 '\n\tFound {}, expected {}').format(fpath, regexp.pattern,
71 print 'Fixing {}...\n'.format(fpath)
80 def check(self, fpath, fix): argument
81 cpp_header = 'grpc++' in fpath or 'grpcpp' in fpath
82 valid_guard = build_valid_guard(fpath)
84 fcontents = load(fpath)
88 print 'something drastically wrong with: %s' % fpath
92 self.fail(fpath, match.re, match.string, '', '', False)
98 fcontents = self.fail(fpath, match.re, match.string, match.group(1),
100 if fix: save(fpath, fcontents)
104 fcontents = self.fail(fpath, match.re, match.string, match.group(1),
106 if fix: save(fpath, fcontents)
112 self.fail(fpath, match.re, match.string, '', '', False)
117 fcontents = self.fail(fpath, match.re, match.string, match.group(1),
119 if fix: save(fpath, fcontents)
135 save(fpath, fcontents)
138 self.fail(fpath, endif_re, flines[-1], '', '', False)
141 fcontents = self.fail(fpath, endif_re, fcontents, match.group(1),
143 if fix: save(fpath, fcontents)