Module sysbot.plugins.data
Data Plugin Module
This module provides functionality for loading and managing data from various file formats (CSV, JSON, YAML) and storing them as secrets in the SysBot cache. Useful for managing test data and configuration files.
Classes
class Data-
Data loader plugin for managing test data from various file formats.
This class provides methods to load data from CSV, JSON, and YAML files and optionally store them in the SysBot secrets cache.
Ancestors
Methods
def csv(self, file: str, key: str = None) ‑> list[dict]-
Load CSV file and optionally store in secrets cache.
Args
file- Path to the CSV file to load.
key- Optional key to store the data in secrets cache. If provided, returns "Imported", otherwise returns the data.
Returns
List of dictionaries representing CSV rows if key is None, otherwise returns "Imported" string after storing in cache.
Raises
FileNotFoundError- If the CSV file does not exist.
RuntimeError- If there's an error reading or parsing the CSV file.
def json(self, file: str, key: str = None) ‑> dict-
Load JSON file and optionally store in secrets cache.
Args
file- Path to the JSON file to load.
key- Optional key to store the data in secrets cache. If provided, returns "Imported", otherwise returns the data.
Returns
Dictionary containing JSON data if key is None, otherwise returns "Imported" string after storing in cache.
Raises
FileNotFoundError- If the JSON file does not exist.
RuntimeError- If there's an error reading or parsing the JSON file.
def yaml(self, file: str, key: str = None) ‑> dict-
Load YAML file and optionally store in secrets cache.
Args
file- Path to the YAML file to load.
key- Optional key to store the data in secrets cache. If provided, returns "Imported", otherwise returns the data.
Returns
Dictionary containing YAML data if key is None, otherwise returns "Imported" string after storing in cache.
Raises
FileNotFoundError- If the YAML file does not exist.
RuntimeError- If there's an error reading or parsing the YAML file.