from typing import OrderedDict


def parse_values(parsed_items):
    """
    Takes the output from parse_items and parses any values or
    properties provided in each item placing the strings into a list.
    If no properties are defined then it will clean up values provided
    and put them in a list of len one.

    Args:
        parsed_sections_dict: dict of dicts containing joined strings
                              found under each item
    Returns:
        result: dictionary of dictionaries containing sections, items,
                and the values provided as a list
    """
    result = OrderedDict()

    for section in parsed_items.keys():
        result[section] = OrderedDict()

        for item, val in parsed_items[section].items():
            value = val.strip()

            # list was provided
            if ',' in val:
                final = [v.strip() for v in value.split(',') if v != '']

            # For use later always make it a list
            else:
                # watch out for items that have commented out values
                if value != '':
                    final = [value]
                else:
                    final = []

            # If there are values provided add them
            if final:
                result[section][item] = final

    return result