<s> def _magic_get_file_type ( f , _ ) : <EOL> file_type = magic . from_buffer ( f . read ( <NUM_LIT> ) , mime = True ) <EOL> f . seek ( <NUM_LIT:0> ) <EOL> return file_type . decode ( '<STR_LIT:utf-8>' ) <EOL> def _guess_file_type ( _ , filename ) : <EOL> return mimetypes . guess_type ( filename ) [ <NUM_LIT:0> ] <EOL> try : <EOL> import magic <EOL> except ImportError : <EOL> import mimetypes <EOL> get_file_type = _guess_file_type <EOL> else : <EOL> get_file_type = _magic_get_file_type </s>
