def _infer_compression(filepath_or_buffer, compression):
 if (compression is None):
  return None
 is_path = isinstance(filepath_or_buffer, compat.string_types)
 if ((compression == 'infer') and (not is_path)):
  return None
 if (compression == 'infer'):
  for (compression, extension) in _compression_to_extension.items():
   if filepath_or_buffer.endswith(extension):
    return compression
  return None
 if (compression in _compression_to_extension):
  return compression
 msg = 'Unrecognized compression type: {}'.format(compression)
 valid = (['infer', None] + sorted(_compression_to_extension))
 msg += '\nValid compression types are {}'.format(valid)
 raise ValueError(msg)

def _infer_compression ( filepath_or_buffer , compression ) : if ( compression is None ) : return None is_path = isinstance ( filepath_or_buffer , compat . string_types ) if ( ( compression == 'infer' ) and ( not is_path ) ) : return None if ( compression == 'infer' ) : for ( compression , extension ) in _compression_to_extension . items ( ) : if filepath_or_buffer . endswith ( extension ) : return compression return None if ( compression in _compression_to_extension ) : return compression msg = 'Unrecognized compression type: {}' . format ( compression ) valid = ( [ 'infer' , None ] + sorted ( _compression_to_extension ) ) msg += '\nValid compression types are {}' . format ( valid ) raise ValueError ( msg )
get the compression method for filepath_or_buffer .