def parse_recipe_list()

in legacy/autopkg_tools/autopkg_tools.py [0:0]


def parse_recipe_list(file_path):
  """Parse a recipe list from a file path. Supports JSON, YAML, or plist."""
  timeprint("Parsing recipe list")
  if not os.path.isfile(file_path):
    timeprint("No recipe list found at that path!")
    sys.exit(-1)
  recipe_list = []
  extension = os.path.splitext(file_path)[1]
  if extension == '.json':
    with open(file_path, 'rb') as f:
      recipe_list = json.load(f)
  elif extension in ('.yaml', '.yml') and YAML_INSTALLED:
    with open(file_path, 'rb') as f:
      recipe_list = yaml.load(f)
  elif extension == '.plist':
    recipe_list = FoundationPlist.readPlist(file_path)
  else:
    raise RunlistError
  display_verbose("Recipe list: %s" % recipe_list)
  return recipe_list