import re


def line_to_dict(lines):
    """ Transforms a group of lines into a list of dictionary

    Args:
        lines (list): A list of lines, the first line contains the keys and the remaining lines contain the values.
                      [
                       [key1    key2   key3],
                       [val11  val12  val12],
                       [val21  val22  val22],
                      ]

    Returns:
        A list of dictionaries.
        [
         {key1: val11, key2: val12, ..},
         {key1: val21, key2: val22, ..}
        ]

    """
    def strip_and_split(line):
        return [word.strip() for word in re.sub(r"^[*|+|~|#|-]", "", line).split('|')[:-1]]

    start_sym = lines[0][0]
    node_type = \
    {'*': 'repos', '+': 'backups', '-': 'buckets', '~': 'scopes', '#': 'collections'}.get(start_sym, 'archives')

    lines = [strip_and_split(line) for line in lines]

    first_line, remaining_lines = lines[0], lines[1:]
    return node_type, [dict(zip(first_line, line)) for line in remaining_lines]