How to use the graphviz.FORMATS function in graphviz

To help you get started, we’ve selected a few graphviz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / turbinia / tools / turbinia_job_graph.py View on Github external
parser = argparse.ArgumentParser(
      description='Create Turbinia evidence graph.')
  parser.add_argument(
      '-f', '--format', default='png',
      help='The format of the output file you wish to generate.  Specify '
      '"list" to list out the available output types.  More info is here: '
      'http://www.graphviz.org/doc/info/output.html')
  parser.add_argument(
      '-e', '--engine', default='dot',
      help='The graphviz engine used to generate the graph layout.  Specify '
      '"list" to list out the available engines.')
  parser.add_argument('filename', type=unicode, help='where to save the file')
  args = parser.parse_args()

  if args.format == 'list':
    formats = ' '.join(graphviz.FORMATS)
    print('Available format types: {0:s}'.format(formats))
    sys.exit(0)

  if args.format not in graphviz.FORMATS:
    print('Format type {0:s} is not supported'.format(args.format))
    sys.exit(1)

  if args.engine == 'list':
    engines = ' '.join(graphviz.ENGINES)
    print('Available graph layout engines: {0:s}'.format(engines))
    sys.exit(0)

  if args.engine not in graphviz.ENGINES:
    print('Layout engine type {0:s} is not supported'.format(args.engine))
    sys.exit(1)
github google / turbinia / tools / turbinia_job_graph.py View on Github external
help='The format of the output file you wish to generate.  Specify '
      '"list" to list out the available output types.  More info is here: '
      'http://www.graphviz.org/doc/info/output.html')
  parser.add_argument(
      '-e', '--engine', default='dot',
      help='The graphviz engine used to generate the graph layout.  Specify '
      '"list" to list out the available engines.')
  parser.add_argument('filename', type=unicode, help='where to save the file')
  args = parser.parse_args()

  if args.format == 'list':
    formats = ' '.join(graphviz.FORMATS)
    print('Available format types: {0:s}'.format(formats))
    sys.exit(0)

  if args.format not in graphviz.FORMATS:
    print('Format type {0:s} is not supported'.format(args.format))
    sys.exit(1)

  if args.engine == 'list':
    engines = ' '.join(graphviz.ENGINES)
    print('Available graph layout engines: {0:s}'.format(engines))
    sys.exit(0)

  if args.engine not in graphviz.ENGINES:
    print('Layout engine type {0:s} is not supported'.format(args.engine))
    sys.exit(1)

  graph = create_graph()
  graph.engine = args.engine
  output_file = args.filename.replace('.png', '')
github biolink / biolink-model / metamodel / generators / dotgen.py View on Github external
@click.option("--format", "-f", default='png', type=click.Choice(sorted(list(FORMATS))), help="Output format")
def cli(yamlfile, directory, out, classname, format):
    """ Generate graphviz representations of the biolink model """
    DotGenerator(yamlfile, format).serialize(classname=classname, dirname=directory, filename=out)
github biolink / biolink-model / metamodel / generators / dotgen.py View on Github external
"""
import os
from typing import TextIO, Union, List, Optional, Set

import click
from graphviz import Digraph, FORMATS

from metamodel.utils.generator import Generator
from metamodel.utils.formatutils import underscore
from metamodel.metamodel import SchemaDefinition, ClassDefinition, SlotDefinition, ClassDefinitionName


class DotGenerator(Generator):
    generatorname = os.path.basename(__file__)
    generatorversion = "0.0.2"
    valid_formats: Set[str] = FORMATS
    visit_all_class_slots = True

    def __init__(self, schema: Union[str, TextIO, SchemaDefinition], fmt: str='png') -> None:
        super().__init__(schema, fmt)
        self.classnames: List[str] = None
        self.filename: Optional[str] = None
        self.dirname: Optional[str] = None
        self.filedot: Optional[Digraph] = None
        self.classdot: Optional[Digraph] = None
        self.cls_subj: Optional[SlotDefinition] = None
        self.cls_obj: Optional[SlotDefinition] = None

    def visit_schema(self, classname: List[str], dirname: Optional[str], filename: Optional[str]) -> None:
        self.classnames = [] if classname is None else list(classname)
        for classname in self.classnames:
            if classname not in self.schema.classes:
github bosnet / isaac-consensus-protocol / examples / star_cluster_scripts / draw-star-cluster.py View on Github external
import argparse
import graphviz
import json
from pprint import pprint  # noqa
import urllib.parse

from star_cluster.star_cluster import get_nodes


parser = argparse.ArgumentParser('Draw the layout of star cluster')
parser.add_argument('-format', default='png', help='image format', type=str, choices=graphviz.FORMATS)
parser.add_argument('-dpi', help='dpi', type=int, default=300)
parser.add_argument('-o', dest='output', required=True, help='output file', type=str)
parser.add_argument('json', help='star cluster json file', type=str)


if __name__ == '__main__':
    options = parser.parse_args()

    with open(options.json) as f:
        data = json.load(f)

    print('> star cluster:')
    pprint(data, width=10)

    quorums = dict()
    node_data = get_nodes(data)
github bosnet / isaac-consensus-protocol / examples / cases / run-case.py View on Github external
parser = ArgumentParserShowDefaults()
logger.set_argparse(parser)

parser.add_argument(
    '-case',
    help='set the case name',
    default=None,
    type=str,
)

parser.add_argument(
    '-viz-format',
    default='png',
    help='network topology image format',
    type=str,
    choices=graphviz.FORMATS,
)
parser.add_argument('-viz-dpi', help='network topology image dpi', type=int, default=300)
parser.add_argument('-viz-output', help='network topology image output file', type=str)

parser.add_argument(
    'design',
    help='design should be yaml or json',
    type=str,
)


parser.add_argument(
    'action',
    nargs='?',
    default='run',
    help='action',
github gil9red / SimplePyScripts / graph__networkx__d3__dot_graphviz / graphviz__examples / print_supported_formats.py View on Github external
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = 'ipetrash'


# pip install graphviz
import graphviz
print(sorted(graphviz.FORMATS))