(filepath, compression)
Get the compression method for ``filepath``, depending on its file extension
    and the value of ``compression``. Also validate the given values.
Get the compression method for ``filepath``, depending on its file extension
    and the value of ``compression``. Also validate the given values.
Get the compression method for filepath depending on its file extension and the value of compression . Also validate the given values .
def _get_compression(filepath, compression):
    """
    Get the compression method for ``filepath``, depending on its file extension
    and the value of ``compression``. Also validate the given values.
    """
    # user has specified "no compression"
    if compression is None:
        return None
    # user wants us to infer compression from filepath
    elif compression == "infer":
        ext = filepath.suffix
        try:
            return _ext_to_compression[ext.lower()]
        except KeyError:
            return None
    # user has specified compression; validate it
    elif compression in _ext_to_compression.values():
        return compression
    else:
        valid_values = [None, "infer"] + sorted(_ext_to_compression.values())
        raise ValueError(
            errors_.value_invalid_msg("compression", compression, valid_values)
        )
def _get_compression ( filepath , compression ) : # user has specified "no compression" if compression is None : return None # user wants us to infer compression from filepath elif compression == "infer" : ext = filepath . suffix try : return _ext_to_compression [ ext . lower ( ) ] except KeyError : return None # user has specified compression; validate it elif compression in _ext_to_compression . values ( ) : return compression else : valid_values = [ None , "infer" ] + sorted ( _ext_to_compression . values ( ) ) raise ValueError ( errors_ . value_invalid_msg ( "compression" , compression , valid_values ) )