Skip to main content

A CLI to convert dot files to bgraph format for visualization.

Project description

dot2bgraph PyPI Travis (.com) Coveralls

dot2bgraph is a CLI utility to convert graphs in dot format to bgraph format, for visualization with tools like bgrapher.

dot2bgraph supports a subset of dot features, tailored specifically to those that convert neatly to bgraph format. Other dot attributes that do not correlate to attributes supported by bgraph (e.g., shapes, label positions, etc.) are ignored.

Installation

First, ensure that you have graphviz installed, since it is a dependency for pygraphviz which, in turn, is a dependency for dot2bgraph.

For example, in Ubuntu:

apt-get install graphviz graphviz-dev

Or in OSX:

brew install graphviz

For other platforms, see pygraphviz's INSTALL.txt

Then, install dot2bgraph:

pip install dot2bgraph

With MacOS you may need to prepend CFLAGS="-I$(brew --prefix graphviz)/include" LDFLAGS="-L$(brew --prefix graphviz)/lib"

Usage

By default an input "file.dot" is converted to bgraph JSON format, which is outputted to stdout:

dot2bgraph file.dot

If you instead wish to quickly look at the output as it would appear in a bgraph visualization tool, use -f png, i.e., "PNG format". For example:

dot2bgraph -f png file.dot

For creating a bgraph recursively from multiple dot files in a directory structure, use -R, e.g. for the following directory structure:

dotdir
├── file1.dot
└── subdotdir
    └── file2.dot

You can run:

dot2bgraph -R dotdir

To save the tool's output (in whichever format) to a file, use -o.

Development

Install

python3 -m venv .venv
source .venv/bin/activate
CFLAGS="-I$(brew --prefix graphviz)/include" LDFLAGS="-L$(brew --prefix graphviz)/lib" python3 -m pip install ".[dev]"

With MacOS you may need to prepend CFLAGS="-I$(brew --prefix graphviz)/include" LDFLAGS="-L$(brew --prefix graphviz)/lib"

Test

Pytest

python -m pytest -s --cov-report term-missing --cov=dot2bgraph

Mypy

python -m mypy -p dot2bgraph --config-file=mypy.ini

Profile

python -mcProfile -o dot2bgraph.prof dot2bgraph/__main__.py -f none <your_dot_file>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dot2bgraph-0.1.2.tar.gz (41.4 kB view hashes)

Uploaded Source

Built Distribution

dot2bgraph-0.1.2-py3-none-any.whl (31.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page