def _find_location(block, directive_name, match_func=None):
    """Finds the index of the first instance of directive_name in block.
       If no line exists, use None."""
    return next((index for index, line in enumerate(block) \
        if line and line[0] == directive_name and (match_func is None or match_func(line))), None)