from pathlib import Path
import glob


def list_temp_files(directory):
    """List all temporary files within a directory which are marked with *temp* in their name"""
    try:
        dir_path = Path(directory)
        assert dir_path.exists()
    except Exception:
        raise Exception(f"Expected absolute path to valid directory, got {directory}")

    temps = glob.glob(str(dir_path / "*temp*"))

    temp_files = [file for file in temps if Path(file).is_file()]

    return temp_files