@@ -75,21 +75,22 @@ 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+ print (mime_type )
82+ if len (mime_type ) == 0 :
83+ mime_type = getMimeType (filename )
8384
8485 if output_lvl > 0 :
85- print ("spell_check_file:" , filename , "," , mimetype )
86+ print ("spell_check_file:" , filename , "," , mime_type )
8687
8788 # Returns a list of comment_parser.parsers.common.Comments
88- if mimetype == 'text/plain' :
89+ if mime_type == 'text/plain' :
8990 clist = load_text_file (filename )
9091 else :
9192 try :
92- clist = comment_parser .extract_comments (filename , mime = mimetype )
93+ clist = comment_parser .extract_comments (filename , mime = mime_type )
9394 except BaseException :
9495 print ("Parser failed, skipping file" , filename )
9596 return []
@@ -216,6 +217,8 @@ def parse_args():
216217 parser .add_argument ('--suffix' , '-s' , action = 'append' , default = [".h" ],
217218 dest = 'suffix' , help = 'File name suffix' )
218219
220+ parser .add_argument ('--type' , '-t' , action = 'store' , default = '' ,
221+ dest = 'mime_type' , help = 'Set file mime type. File name suffix will be ignored.' )
219222 args = parser .parse_args ()
220223 return args
221224
@@ -304,7 +307,7 @@ def main():
304307
305308 if not args .miss :
306309 print ("\n Checking" , x )
307- result = spell_check_file (x , spell_checker ,
310+ result = spell_check_file (x , spell_checker , args . mime_type ,
308311 output_lvl = output_lvl ,
309312 prefixes = prefixes )
310313 bad_words = sorted (bad_words + result )
@@ -317,7 +320,7 @@ def main():
317320 continue
318321
319322 # f is a file, so spell check it
320- result = spell_check_file (f , spell_checker ,
323+ result = spell_check_file (f , spell_checker , args . mime_type ,
321324 output_lvl = output_lvl , prefixes = prefixes )
322325
323326 bad_words = sorted (bad_words + result )
0 commit comments