def _flatten_log(log):
    """
    Convert the nested-dict log format to a list of lovestate dicts.

    The log is typically dictionaries of read/unread information,
    in a doubly-nested dictionary indexed by the plan name and the
    snippet. This converts that structure into a list of those dicts,
    where the former indices (plan name and snippet) are added as
    two extra entries to that dictionary.

    """
    flattened = []
    for un, snips in sorted(log.items()):
        for snip, lovestate in sorted(snips.items()):
            lovestate = dict(lover=un, text=snip, **lovestate)
            flattened.append(lovestate)
    return flattened
