def _get_valid_format(mode, cls, path, fileobj, args, kwargs):
 valid_formats = identify_format(mode, cls, path, fileobj, args, kwargs)
 if (len(valid_formats) == 0):
  format_table_str = _get_format_table_str(cls, mode.capitalize())
  raise IORegistryError(u'Format could not be identified.\nThe available formats are:\n{0}'.format(format_table_str))
 elif (len(valid_formats) > 1):
  raise IORegistryError(u'Format is ambiguous - options are: {0}'.format(u', '.join(sorted(valid_formats, key=itemgetter(0)))))
 return valid_formats[0]

def _get_valid_format ( mode , cls , path , fileobj , args , kwargs ) : valid_formats = identify_format ( mode , cls , path , fileobj , args , kwargs ) if ( len ( valid_formats ) == 0 ) : format_table_str = _get_format_table_str ( cls , mode . capitalize ( ) ) raise IORegistryError ( u'Format could not be identified.\nThe available formats are:\n{0}' . format ( format_table_str ) ) elif ( len ( valid_formats ) > 1 ) : raise IORegistryError ( u'Format is ambiguous - options are: {0}' . format ( u', ' . join ( sorted ( valid_formats , key = itemgetter ( 0 ) ) ) ) ) return valid_formats [ 0 ]
returns the first valid format that can be used to read/write the data in question .