Add ?format=toml support to /recipes/info/
This will return the recipe in TOML format. Note that this does not include any extra information about errors. Just the recipes, any unrecognized recipe names will be skipped.
This commit is contained in:
parent
b0d91204a4
commit
413964b92f
@ -959,6 +959,7 @@ def v0_api(api):
|
|||||||
def v0_recipes_info(recipe_names):
|
def v0_recipes_info(recipe_names):
|
||||||
"""Return the contents of the recipe, or a list of recipes"""
|
"""Return the contents of the recipe, or a list of recipes"""
|
||||||
branch = request.args.get("branch", "master")
|
branch = request.args.get("branch", "master")
|
||||||
|
out_fmt = request.args.get("format", "json")
|
||||||
recipes = []
|
recipes = []
|
||||||
changes = []
|
changes = []
|
||||||
errors = []
|
errors = []
|
||||||
@ -1003,7 +1004,11 @@ def v0_api(api):
|
|||||||
recipes = sorted(recipes, key=lambda r: r["name"].lower())
|
recipes = sorted(recipes, key=lambda r: r["name"].lower())
|
||||||
errors = sorted(errors, key=lambda e: e["recipe"].lower())
|
errors = sorted(errors, key=lambda e: e["recipe"].lower())
|
||||||
|
|
||||||
return jsonify(changes=changes, recipes=recipes, errors=errors)
|
if out_fmt == "toml":
|
||||||
|
# With TOML output we just want to dump the raw recipe, skipping the rest.
|
||||||
|
return "\n\n".join([r.toml() for r in recipes])
|
||||||
|
else:
|
||||||
|
return jsonify(changes=changes, recipes=recipes, errors=errors)
|
||||||
|
|
||||||
@api.route("/api/v0/recipes/changes/<recipe_names>")
|
@api.route("/api/v0/recipes/changes/<recipe_names>")
|
||||||
@crossdomain(origin="*")
|
@crossdomain(origin="*")
|
||||||
|
Loading…
Reference in New Issue
Block a user