How to use the graphviz.backend.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 pypa / pipenv / pipenv / vendor / pipdeptree.py View on Github external
"""Output dependency graph as one of the supported GraphViz output formats.

    :param dict tree: dependency graph
    :param string output_format: output format
    :returns: representation of tree in the specified output format
    :rtype: str or binary representation depending on the output format

    """
    try:
        from graphviz import backend, Digraph
    except ImportError:
        print('graphviz is not available, but necessary for the output '
              'option. Please install it.', file=sys.stderr)
        sys.exit(1)

    if output_format not in backend.FORMATS:
        print('{0} is not a supported output format.'.format(output_format),
              file=sys.stderr)
        print('Supported formats are: {0}'.format(
            ', '.join(sorted(backend.FORMATS))), file=sys.stderr)
        sys.exit(1)

    graph = Digraph(format=output_format)
    for package, deps in tree.items():
        project_name = package.project_name
        label = '{0}\n{1}'.format(project_name, package.version)
        graph.node(project_name, label=label)
        for dep in deps:
            label = dep.version_spec
            if not label:
                label = 'any'
            graph.edge(project_name, dep.project_name, label=label)
github pypa / pipenv / pipenv / vendor / pipdeptree.py View on Github external
:returns: representation of tree in the specified output format
    :rtype: str or binary representation depending on the output format

    """
    try:
        from graphviz import backend, Digraph
    except ImportError:
        print('graphviz is not available, but necessary for the output '
              'option. Please install it.', file=sys.stderr)
        sys.exit(1)

    if output_format not in backend.FORMATS:
        print('{0} is not a supported output format.'.format(output_format),
              file=sys.stderr)
        print('Supported formats are: {0}'.format(
            ', '.join(sorted(backend.FORMATS))), file=sys.stderr)
        sys.exit(1)

    graph = Digraph(format=output_format)
    for package, deps in tree.items():
        project_name = package.project_name
        label = '{0}\n{1}'.format(project_name, package.version)
        graph.node(project_name, label=label)
        for dep in deps:
            label = dep.version_spec
            if not label:
                label = 'any'
            graph.edge(project_name, dep.project_name, label=label)

    # Allow output of dot format, even if GraphViz isn't installed.
    if output_format == 'dot':
        return graph.source
github naiquevin / pipdeptree / pipdeptree.py View on Github external
:returns: representation of tree in the specified output format
    :rtype: str or binary representation depending on the output format

    """
    try:
        from graphviz import backend, Digraph
    except ImportError:
        print('graphviz is not available, but necessary for the output '
              'option. Please install it.', file=sys.stderr)
        sys.exit(1)

    if output_format not in backend.FORMATS:
        print('{0} is not a supported output format.'.format(output_format),
              file=sys.stderr)
        print('Supported formats are: {0}'.format(
            ', '.join(sorted(backend.FORMATS))), file=sys.stderr)
        sys.exit(1)

    graph = Digraph(format=output_format)
    for package, deps in tree.items():
        project_name = package.project_name
        label = '{0}\n{1}'.format(project_name, package.version)
        graph.node(project_name, label=label)
        for dep in deps:
            label = dep.version_spec
            if not label:
                label = 'any'
            graph.edge(project_name, dep.project_name, label=label)

    # Allow output of dot format, even if GraphViz isn't installed.
    if output_format == 'dot':
        return graph.source
github fossas / fossa-cli / analyzers / python / bindata / pipdeptree.py View on Github external
"""Output dependency graph as one of the supported GraphViz output formats.

    :param dict tree: dependency graph
    :param string output_format: output format
    :returns: representation of tree in the specified output format
    :rtype: str or binary representation depending on the output format

    """
    try:
        from graphviz import backend, Digraph
    except ImportError:
        print('graphviz is not available, but necessary for the output '
              'option. Please install it.', file=sys.stderr)
        sys.exit(1)

    if output_format not in backend.FORMATS:
        print('{0} is not a supported output format.'.format(output_format),
              file=sys.stderr)
        print('Supported formats are: {0}'.format(
            ', '.join(sorted(backend.FORMATS))), file=sys.stderr)
        sys.exit(1)

    graph = Digraph(format=output_format)
    for package, deps in tree.items():
        project_name = package.project_name
        label = '{0}\n{1}'.format(project_name, package.version)
        graph.node(project_name, label=label)
        for dep in deps:
            label = dep.version_spec
            if not label:
                label = 'any'
            graph.edge(project_name, dep.project_name, label=label)
github HDI-Project / SDV / sdv / metadata / visualization.py View on Github external
def _get_graphviz_extension(path):
    if path:
        path_splitted = path.split('.')
        if len(path_splitted) == 1:
            raise ValueError('Path without graphviz extansion.')

        graphviz_extension = path_splitted[-1]

        if graphviz_extension not in graphviz.backend.FORMATS:
            raise ValueError(
                '"{}" not a valid graphviz extension format.'.format(graphviz_extension)
            )

        return '.'.join(path_splitted[:-1]), graphviz_extension

    return None, None
github fossas / fossa-cli / analyzers / python / bindata / pipdeptree.py View on Github external
:returns: representation of tree in the specified output format
    :rtype: str or binary representation depending on the output format

    """
    try:
        from graphviz import backend, Digraph
    except ImportError:
        print('graphviz is not available, but necessary for the output '
              'option. Please install it.', file=sys.stderr)
        sys.exit(1)

    if output_format not in backend.FORMATS:
        print('{0} is not a supported output format.'.format(output_format),
              file=sys.stderr)
        print('Supported formats are: {0}'.format(
            ', '.join(sorted(backend.FORMATS))), file=sys.stderr)
        sys.exit(1)

    graph = Digraph(format=output_format)
    for package, deps in tree.items():
        project_name = package.project_name
        label = '{0}\n{1}'.format(project_name, package.version)
        graph.node(project_name, label=label)
        for dep in deps:
            label = dep.version_spec
            if not label:
                label = 'any'
            graph.edge(project_name, dep.project_name, label=label)

    # Allow output of dot format, even if GraphViz isn't installed.
    if output_format == 'dot':
        return graph.source
github naiquevin / pipdeptree / pipdeptree.py View on Github external
"""Output dependency graph as one of the supported GraphViz output formats.

    :param dict tree: dependency graph
    :param string output_format: output format
    :returns: representation of tree in the specified output format
    :rtype: str or binary representation depending on the output format

    """
    try:
        from graphviz import backend, Digraph
    except ImportError:
        print('graphviz is not available, but necessary for the output '
              'option. Please install it.', file=sys.stderr)
        sys.exit(1)

    if output_format not in backend.FORMATS:
        print('{0} is not a supported output format.'.format(output_format),
              file=sys.stderr)
        print('Supported formats are: {0}'.format(
            ', '.join(sorted(backend.FORMATS))), file=sys.stderr)
        sys.exit(1)

    graph = Digraph(format=output_format)
    for package, deps in tree.items():
        project_name = package.project_name
        label = '{0}\n{1}'.format(project_name, package.version)
        graph.node(project_name, label=label)
        for dep in deps:
            label = dep.version_spec
            if not label:
                label = 'any'
            graph.edge(project_name, dep.project_name, label=label)
github xflr6 / graphviz / graphviz / files.py View on Github external
def format(self, format):
        format = format.lower()
        if format not in backend.FORMATS:
            raise ValueError('unknown format: %r' % format)
        self._format = format
github AnyBlok / AnyBlok / anyblok / config.py View on Github external
def add_schema(group):
    try:
        from graphviz.files import FORMATS
    except ImportError:
        from graphviz.backend import FORMATS

    group.add_argument('--schema-format',
                       default='png', choices=tuple(FORMATS))