code: def guess_format( filename, ext, formats, io_table ):
      
      ok = False
      for format in formats:
          output( 'guessing %s' % format )
          try:
              ok = io_table[format].guess( filename )
          except AttributeError:
              pass
          if ok: break
  
      else:
          raise NotImplementedError('cannot guess format of a *%s file!' % ext)
  
      return format
docs: Guess the format of filename, candidates are in formats.