def _get_order_patch(order_text, seq_to_name):
    """Create a mapping from a key sequence to a list of sequence, name tuples.
    This will be used to insert additional sequences after the key sequence
    in the order data.  seq_to_name is a mapping from new sequence to name,
    so the names don't have to be duplicated in the order data."""

    patch_map = {}
    patch_key = None
    patch_list = None

    def get_sequence(seqtext):
        return tuple([int(s, 16) for s in seqtext.split()])

    for line in order_text.splitlines():
        ix = line.find("#")
        if ix >= 0:
            line = line[:ix]
        line = line.strip()
        if not line:
            continue
        if line.startswith("-"):
            if patch_list and patch_key:
                patch_map[patch_key] = patch_list
            patch_key = get_sequence(line[1:])
            patch_list = []
        else:
            seq = get_sequence(line)
            name = seq_to_name[seq]  # exception if seq is not in sequence_text
            patch_list.append((seq, name))
    if patch_list and patch_key:
        patch_map[patch_key] = patch_list

    return patch_map