Graphviz utility functions.
Project description
Graphviz utility functions.
Latest release 20220827.1: gvprint: new optional parameter dataurl_encoding to specify the data URL encoding.
See also the [https://www.graphviz.org/documentation/](graphviz documentation)
and particularly the [https://graphviz.org/doc/info/lang.html](DOT language specification)
and the [https://www.graphviz.org/doc/info/command.html](dot
command line tool).
Class DOTNodeMixin
A mixin providing methods for things which can be drawn as nodes in a DOT graph description.
Function gvdata(dot_s, **kw)
Convenience wrapper for gvprint
which returns the binary image data.
Function gvdataurl(dot_s, **kw)
Convenience wrapper for gvprint
which returns the binary image data
as a data:
URL.
Function gvprint(dot_s, file=None, fmt=None, layout=None, dataurl_encoding=None, **dot_kw)
Print the graph specified by dot_s
, a graph in graphViz DOT syntax,
to file
(default sys.stdout
)
in format fmt
using the engine specified by layout
(default 'dot'
).
If fmt
is unspecified it defaults to 'png'
unless file
is a terminal in which case it defaults to 'sixel'
.
In addition to being a file or file descriptor,
file
may also take the following special values:
GVCAPTURE
: causesgvprint
to return the image data asbytes
GVDATAURL
: causesgvprint
to return the image data as adata:
URL
For GVDATAURL
, the parameter dataurl_encoding
may be used
to override the default encoding, which is 'utf8'
for fmt
values 'dot'
and 'svg'
, otherwise 'base64'
.
This uses the graphviz utility dot
to draw graphs.
If printing in SIXEL format the img2sixel
utility is required,
see https://saitoha.github.io/libsixel/.
Example:
data_url = gvprint('digraph FOO {A->B}', file=GVDATAURL, fmt='svg')
produces a data:
URL rendering as:
Function quote(s)
Quote a string for use in DOT syntax. This implementation passes identifiers and sequences of decimal numerals through unchanged and double quotes other strings.
Release Log
Release 20220827.1: gvprint: new optional parameter dataurl_encoding to specify the data URL encoding.
Release 20220827:
- Remove dependency on cs.lex - now we need only the stdlib.
- New GVCAPTURE value for gvprint(file=) to return the binary image data as a bytes object; associated gvdata() convenience function.
- New GVDATAURL value for gvprint(file=) to return the binary image data as a data URL; associated gvdataurl() convenience function.
Release 20220805.1: New DOTNodeMixin, a mixin for classes which can be rendered as a DOT node.
Release 20220805: Initial PyPI release.
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
File details
Details for the file cs.gvutils-20220827.1.tar.gz
.
File metadata
- Download URL: cs.gvutils-20220827.1.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.1 readme-renderer/30.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.3.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f32aa6525dedce7fc5e0f6d2753d05f44d98ccf392b4a37a82cbe9bd2053a2f |
|
MD5 | 1678eb8906c409385833ed3959b21718 |
|
BLAKE2b-256 | f3c96a1e08415c37492f981852ce248b9532edadc607fd86e6e33ae4d28f1552 |
File details
Details for the file cs.gvutils-20220827.1-py3-none-any.whl
.
File metadata
- Download URL: cs.gvutils-20220827.1-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.1 readme-renderer/30.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.3.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ac5932300dc87dfca9b2305e70e3b0272d0f232a4264cbf5dd90f6822c37a38 |
|
MD5 | e9138867e21c890be7bb23831dfa6ca5 |
|
BLAKE2b-256 | 7c37af51eb5d2ed913222180a39d6e3d8648f1ce9c36904fa0b887bb827e4437 |