colander_data_converter.exporters.graphviz

class colander_data_converter.exporters.graphviz.GraphvizExporter(feed, theme=None)[source]

Bases: BaseExporter

Exporter for generating Graphviz DOT format files from Colander data feeds.

This exporter creates Graphviz-compatible DOT format output that can be used to visualize entity relationships and hierarchies. It uses Jinja2 templates for rendering and supports customizable themes for styling the generated graphs.

The exporter automatically loads a default theme if none is provided, ensuring consistent visual output. The theme controls various visual aspects like colors, shapes, and styling attributes for different entity types.

__init__(feed, theme=None)[source]

Initialize the GraphvizExporter with feed data and optional theme configuration.

Sets up the exporter with the provided data feed and theme. If no theme is provided, loads the default theme from the package resources. Initializes the internal TemplateExporter with the Graphviz template.

Parameters:
  • feed (ColanderFeed) – The data feed containing entities to be exported. This feed will be processed and converted to Graphviz DOT format.

  • theme (dict, optional) – Theme configuration dictionary that controls the visual styling of the generated graph. If None, the default theme will be loaded automatically.

export(output, **kwargs)[source]

Export the feed data as Graphviz DOT format to the specified output stream.

Renders the Colander data feed using the configured Jinja2 template and theme to produce Graphviz DOT format output. The theme is passed to the template as a context variable, allowing the template to apply consistent styling.

Parameters:
  • output (TextIO) – A text-based output stream where the DOT format content will be written. This can be a file object, StringIO, or any object implementing the TextIO interface.

  • **kwargs – Additional keyword arguments that will be passed to the underlying TemplateExporter. These can be used to provide additional context variables to the Jinja2 template.

Raises:

Note

The generated DOT format can be processed by Graphviz tools (dot, neato, etc.) to create visual representations in various formats (PNG, SVG, PDF, etc.). The theme dictionary is automatically passed to the template as the ‘theme’ variable.

load_default_theme()[source]

Load the default theme configuration from the package resources.

Reads the default theme JSON file from the package’s data/themes directory and loads it into the theme attribute. This method is automatically called during initialization if no custom theme is provided.