import plistlib


def parse_recipe_list(filename):
    """Parses a recipe list. This can be either a simple list of recipes to run,
    or a plist containing recipes and other key/value pairs"""
    recipe_list = {}
    try:
        with open(filename, "rb") as f:
            plist = plistlib.load(f)
        if not plist.get("recipes"):
            # try to trigger an AttributeError if the plist is not a dict
            pass
        return plist
    except Exception:
        # file does not appear to be a plist containing a dictionary;
        # read it as a plaintext list of recipes
        with open(filename, "r") as file_desc:
            data = file_desc.read()
        recipe_list["recipes"] = [
            line for line in data.splitlines() if line and not line.startswith("#")
        ]
    return recipe_list