@@ -75,21 +75,21 @@ def load_text_file(filename):
7575
7676# The main spell checking procedure
7777#
78- def spell_check_file (filename , spell_checker , mimetype = '' ,
78+ def spell_check_file (filename , spell_checker , mime_type = '' ,
7979 output_lvl = 1 , prefixes = []):
8080
81- if len (mimetype ) == 0 :
82- mimetype = getMimeType (filename )
81+ if len (mime_type ) == 0 :
82+ mime_type = getMimeType (filename )
8383
8484 if output_lvl > 0 :
85- print ("spell_check_file:" , filename , "," , mimetype )
85+ print ("spell_check_file:" , filename , "," , mime_type )
8686
8787 # Returns a list of comment_parser.parsers.common.Comments
88- if mimetype == 'text/plain' :
88+ if mime_type == 'text/plain' :
8989 clist = load_text_file (filename )
9090 else :
9191 try :
92- clist = comment_parser .extract_comments (filename , mime = mimetype )
92+ clist = comment_parser .extract_comments (filename , mime = mime_type )
9393 except BaseException :
9494 print ("Parser failed, skipping file" , filename )
9595 return []
@@ -216,6 +216,8 @@ def parse_args():
216216 parser .add_argument ('--suffix' , '-s' , action = 'append' , default = [".h" ],
217217 dest = 'suffix' , help = 'File name suffix' )
218218
219+ parser .add_argument ('--type' , '-t' , action = 'store' , default = '' ,
220+ dest = 'mime_type' , help = 'Set file mime type. File name suffix will be ignored.' )
219221 args = parser .parse_args ()
220222 return args
221223
@@ -304,7 +306,7 @@ def main():
304306
305307 if not args .miss :
306308 print ("\n Checking" , x )
307- result = spell_check_file (x , spell_checker ,
309+ result = spell_check_file (x , spell_checker , args . mime_type ,
308310 output_lvl = output_lvl ,
309311 prefixes = prefixes )
310312 bad_words = sorted (bad_words + result )
@@ -317,7 +319,7 @@ def main():
317319 continue
318320
319321 # f is a file, so spell check it
320- result = spell_check_file (f , spell_checker ,
322+ result = spell_check_file (f , spell_checker , args . mime_type ,
321323 output_lvl = output_lvl , prefixes = prefixes )
322324
323325 bad_words = sorted (bad_words + result )
0 commit comments