def parse_properties(properties):
    """
    Return a dictionary of attributes based on properties.
    Convert properties of form "property1=value1,property2=value2, ..."
    to {'property1': value1, 'property2': value2, ...}.
    """
    pairs = [
        (k.strip(), eval(v.strip()))
        for k, v in
        [prop.split('=', 1) for prop in properties.split(',')]
    ]

    attrs = dict()
    for k, v in pairs:
        if k in attrs:
            if not isinstance(attrs[k], list):
                attrs[k] = [attrs[k]]
            attrs[k].append(v)
        else:
            attrs[k] = v

    return attrs