import toml


def environment(file, transect):
    """
    Read environmental metadata, temperature and salinity, from the file
    "transects.toml".
    
    Args:
        file     (str): path to transects.toml.
        transect (str): Name of transect.
        
    Returns:
        float: Temperature (degrees Celsius)
        float: Salinity    (PSU)
    """

    data     = toml.load(file)
    try:
        data = [x for x in data['transect'] if x['name']==transect][0]
    except IndexError:
        raise Exception('Transect name doesn\'t exist')    
    
    temperature = data['temperature']
    salinity    = data['salinity']
    
    return temperature, salinity