blob: 0cd2fbe994f2ffec817b5004ab89a3cd8bbf50a2 [file] [log] [blame]
# Copyright 2023 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
from recipe_engine import recipe_api
class TomlApi(recipe_api.RecipeApi):
"""Provides functions to parse TOML files."""
def read_file(self, name, file_path, test_data=None):
"""Parse a TOML file and return its content as a dictionary.
Args:
name (str): The step name to assign.
file_path (Path): The path to the TOML file.
test_data (dict or list): Mock TOML data to return.
"""
return self.m.step(
name,
[self.resource("parse_toml.py"), file_path],
stdout=self.m.json.output(),
step_test_data=lambda: self.m.json.test_api.output_stream(test_data),
).stdout