import glob
from pathlib import Path


def get_mas_variables(path):
    """
    Return a list of variables present in a given directory.

    Parameters
    ----------
    path :
        Path to the folder containing the MAS data files.

    Returns
    -------
    var_names : list
        List of variable names present in the given directory.
    """
    files = glob.glob(str(path / '*[0-9][0-9][0-9].*'))
    # Get the variable name from the filename
    # Here we take the filename before .hdf, and remove the last three
    # characters which give the timestep
    var_names = [Path(f).stem.split('.')[0][:-3] for f in files]
    if not len(var_names):
        raise FileNotFoundError(f'No variable files found in {path}')
    # Use list(set()) to get unique values
    return list(set(var_names))