@@ -130,7 +130,6 @@ def list_files_from_directory(path, recurse):
130
130
in FILE_TYPE_EXTENSIONS.
131
131
"""
132
132
filenames = []
133
-
134
133
for root , dirs , files in os .walk (path ):
135
134
for filename in files :
136
135
if filename .endswith (FILE_TYPE_EXTENSIONS ):
@@ -177,12 +176,19 @@ def validate_arguments():
177
176
return False
178
177
return True
179
178
180
- def is_file_objc (filename ):
181
- # Only detect header files since we already filter out other
182
- # file types by extensions.
179
+ def is_file_objc_header (filename ):
180
+ """Checks the contents of the file to determine if it contains language
181
+ constructs that appear in obj-c but not in C/C++.
182
+
183
+ Args:
184
+ filename (string): the name of the file to check
185
+
186
+ Returns:
187
+ bool: True if the header file contains known obj-c language definitions.
188
+ Returns False otherwise.
189
+ """
183
190
if '.h' not in filename :
184
191
return False
185
-
186
192
objective_c_tags = [ '@end' , '@class' , '#import' ]
187
193
for line in open (filename ):
188
194
for tag in objective_c_tags :
@@ -216,17 +222,17 @@ def main(argv):
216
222
count = 0
217
223
for filename in filenames :
218
224
if does_file_need_formatting (filename ):
219
- if is_file_objc (filename ):
225
+ if is_file_objc_header (filename ):
220
226
if FLAGS .verbose :
221
227
print (' - Ignoring obj header: "{0}"' .format (filename ))
222
228
else :
223
229
if FLAGS .verbose :
224
- print (' - Formatting : "{0}"' .format (filename ))
230
+ print (' - FRMT : "{0}"' .format (filename ))
225
231
format_file (filename )
226
232
count += 1
227
233
else :
228
234
if FLAGS .verbose :
229
- print (' - OK: "{0}"' .format (filename ))
235
+ print (' - OK: "{0}"' .format (filename ))
230
236
print (' > Formatted {0} file(s).' .format (count ))
231
237
else :
232
238
count = 0
0 commit comments