def guess_ext(fname, sniff_order, is_multi_byte=False):
 file_ext = None
 for datatype in sniff_order:
  '\n        Some classes may not have a sniff function, which is ok.  In fact, the\n        Tabular and Text classes are 2 examples of classes that should never have\n        a sniff function.  Since these classes are default classes, they contain\n        few rules to filter out data of other formats, so they should be called\n        from this function after all other datatypes in sniff_order have not been\n        successfully discovered.\n        '
  try:
   if datatype.sniff(fname):
    file_ext = datatype.file_ext
    break
  except:
   pass
 if (file_ext == 'tsv'):
  if is_column_based(fname, ' DCTB ', 1, is_multi_byte=is_multi_byte):
   file_ext = 'tabular'
 if (file_ext is not None):
  return file_ext
 headers = get_headers(fname, None)
 is_binary = False
 if is_multi_byte:
  is_binary = False
 else:
  for hdr in headers:
   for char in hdr:
    is_binary = util.is_binary(char)
    if is_binary:
     break
   if is_binary:
    break
 if is_binary:
  return 'data'
 if is_column_based(fname, ' DCTB ', 1, is_multi_byte=is_multi_byte):
  return 'tabular'
 return 'txt'

def guess_ext ( fname , sniff_order , is_multi_byte = False ) : file_ext = None for datatype in sniff_order : try : if datatype . sniff ( fname ) : file_ext = datatype . file_ext break except : pass if ( file_ext == 'tsv' ) : if is_column_based ( fname , ' DCTB ' , 1 , is_multi_byte = is_multi_byte ) : file_ext = 'tabular' if ( file_ext is not None ) : return file_ext headers = get_headers ( fname , None ) is_binary = False if is_multi_byte : is_binary = False else : for hdr in headers : for char in hdr : is_binary = util . is_binary ( char ) if is_binary : break if is_binary : break if is_binary : return 'data' if is_column_based ( fname , ' DCTB ' , 1 , is_multi_byte = is_multi_byte ) : return 'tabular' return 'txt'
returns an extension that can be used in the datatype factory to generate a data for the fname file .