A CLI to convert dot files to bgraph format for visualization.
Project description
dot2bgraph
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for dot2bgraph-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51d93f7248b753ab8245df0e594ed7160d360e30e773dc8c7514105ab377611a |
|
MD5 | 95659e7b1f1e886b1560a7736f94f918 |
|
BLAKE2b-256 | 7476cc736b63e4a9fce09da9096a3ef4301de31cc02ae3dda761c5f0ea609e57 |