import re


def compile_map(old_map, section):
    """Compile the regular expressions in a map.

    Parameters
    ----------
    old_map : :class:`dict`
        A dictionary containing regular expressions to compile.
    section : :class:`str`
        An initial key to determine the section of the dictionary of interest.
        Typically, this will be a top-level directory.

    Returns
    -------
    :class:`dict`
        A new dictionary containing compiled regular expressions.
    """
    new_map = dict()
    for key in old_map[section]:
        if key == '__exclude__':
            new_map[key] = frozenset(old_map[section][key])
        else:
            foo = list()
            for r in old_map[section][key]:
                foo.append((re.compile(r), old_map[section][key][r]))
            new_map[key] = tuple(foo)
    return new_map