Graphviz utility functions.
*Latest release 20230816*:
DOTNodeMixin: new dot_node_attrs_str for transcribing a node attributes list.
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`: causes `gvprint` to return the image data as `bytes`
* `GVDATAURL`: causes `gvprint` to return the image data as a `data:` 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/](libsixel).
Example:
data_url = gvprint('digraph FOO {A->B}', file=GVDATAURL, fmt='svg')
## Function `gvsvg(dot_s, **kw)`
Convenience wrapper for `gvprint` which returns an SVG string.
## 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 20230816*:
DOTNodeMixin: new dot_node_attrs_str for transcribing a node attributes list.
*Release 20221207*:
New gvsvg() convenience function to return SVG.
*Release 20221118*:
* quote: provide escape sequence for newline.
* DOTNodeMixin: provide .dot_node_id property, default `str(id(self))`.
* DOTNodeMixin.dot_node: omit [attrs] if they are empty.
* DOTNodeMixin: new .dot_node_palette_key property, new __getattr__ for .dot_node_*color attributes, new empty default DOT_NODE_COLOR_PALETTE and DOT_NODE_FILLCOLOR_PALETTE class attributes.
* DOTNodeMixin.dot_node: include the node label in the attributes.
* Add colours to DOTNodeMixin.dot_node_attrs and fix "fontcolor".
*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.
Raw data
{
"_id": null,
"home_page": "https://bitbucket.org/cameron_simpson/css/commits/all",
"name": "cs.gvutils",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "python3",
"author": "Cameron Simpson",
"author_email": "Cameron Simpson <cs@cskk.id.au>",
"download_url": "https://files.pythonhosted.org/packages/d3/96/bf0a9affae4e83aac8deac720d6f8470c19bd30cb56c4de1c779abb1175f/cs.gvutils-20230816.tar.gz",
"platform": null,
"description": "Graphviz utility functions.\n\n*Latest release 20230816*:\nDOTNodeMixin: new dot_node_attrs_str for transcribing a node attributes list.\n\nSee also the [https://www.graphviz.org/documentation/](graphviz documentation)\nand particularly the [https://graphviz.org/doc/info/lang.html](DOT language specification)\nand the [https://www.graphviz.org/doc/info/command.html](`dot` command line tool).\n\n## Class `DOTNodeMixin`\n\nA mixin providing methods for things which can be drawn as\nnodes in a DOT graph description.\n\n## Function `gvdata(dot_s, **kw)`\n\nConvenience wrapper for `gvprint` which returns the binary image data.\n\n## Function `gvdataurl(dot_s, **kw)`\n\nConvenience wrapper for `gvprint` which returns the binary image data\nas a `data:` URL.\n\n## Function `gvprint(dot_s, file=None, fmt=None, layout=None, dataurl_encoding=None, **dot_kw)`\n\nPrint the graph specified by `dot_s`, a graph in graphViz DOT syntax,\nto `file` (default `sys.stdout`)\nin format `fmt` using the engine specified by `layout` (default `'dot'`).\n\nIf `fmt` is unspecified it defaults to `'png'` unless `file`\nis a terminal in which case it defaults to `'sixel'`.\n\nIn addition to being a file or file descriptor,\n`file` may also take the following special values:\n* `GVCAPTURE`: causes `gvprint` to return the image data as `bytes`\n* `GVDATAURL`: causes `gvprint` to return the image data as a `data:` URL\n\nFor `GVDATAURL`, the parameter `dataurl_encoding` may be used\nto override the default encoding, which is `'utf8'` for `fmt`\nvalues `'dot'` and `'svg'`, otherwise `'base64'`.\n\nThis uses the graphviz utility `dot` to draw graphs.\nIf printing in SIXEL format the `img2sixel` utility is required,\nsee [https://saitoha.github.io/libsixel/](libsixel).\n\nExample:\n\n data_url = gvprint('digraph FOO {A->B}', file=GVDATAURL, fmt='svg')\n\n## Function `gvsvg(dot_s, **kw)`\n\nConvenience wrapper for `gvprint` which returns an SVG string.\n\n## Function `quote(s)`\n\nQuote a string for use in DOT syntax.\nThis implementation passes identifiers and sequences of decimal numerals\nthrough unchanged and double quotes other strings.\n\n# Release Log\n\n\n\n*Release 20230816*:\nDOTNodeMixin: new dot_node_attrs_str for transcribing a node attributes list.\n\n*Release 20221207*:\nNew gvsvg() convenience function to return SVG.\n\n*Release 20221118*:\n* quote: provide escape sequence for newline.\n* DOTNodeMixin: provide .dot_node_id property, default `str(id(self))`.\n* DOTNodeMixin.dot_node: omit [attrs] if they are empty.\n* DOTNodeMixin: new .dot_node_palette_key property, new __getattr__ for .dot_node_*color attributes, new empty default DOT_NODE_COLOR_PALETTE and DOT_NODE_FILLCOLOR_PALETTE class attributes.\n* DOTNodeMixin.dot_node: include the node label in the attributes.\n* Add colours to DOTNodeMixin.dot_node_attrs and fix \"fontcolor\".\n\n*Release 20220827.1*:\ngvprint: new optional parameter dataurl_encoding to specify the data URL encoding.\n\n*Release 20220827*:\n* Remove dependency on cs.lex - now we need only the stdlib.\n* New GVCAPTURE value for gvprint(file=) to return the binary image data as a bytes object; associated gvdata() convenience function.\n* New GVDATAURL value for gvprint(file=) to return the binary image data as a data URL; associated gvdataurl() convenience function.\n\n*Release 20220805.1*:\nNew DOTNodeMixin, a mixin for classes which can be rendered as a DOT node.\n\n*Release 20220805*:\nInitial PyPI release.\n",
"bugtrack_url": null,
"license": "GNU General Public License v3 or later (GPLv3+)",
"summary": "Graphviz utility functions.",
"version": "20230816",
"project_urls": {
"Homepage": "https://bitbucket.org/cameron_simpson/css/commits/all",
"URL": "https://bitbucket.org/cameron_simpson/css/commits/all"
},
"split_keywords": [
"python3"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "dfabeff414fe03b32e8957f9df57062f2981b49603d63c5e9168cb77c26a2cc4",
"md5": "26e6ad7a81b7e888920e78485c3049a7",
"sha256": "fbcd1f3f7881bd32820b9588d939209cff5f0527031ea0fcb174e81ee515de7f"
},
"downloads": -1,
"filename": "cs.gvutils-20230816-py3-none-any.whl",
"has_sig": false,
"md5_digest": "26e6ad7a81b7e888920e78485c3049a7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 6455,
"upload_time": "2023-08-16T07:07:31",
"upload_time_iso_8601": "2023-08-16T07:07:31.650783Z",
"url": "https://files.pythonhosted.org/packages/df/ab/eff414fe03b32e8957f9df57062f2981b49603d63c5e9168cb77c26a2cc4/cs.gvutils-20230816-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d396bf0a9affae4e83aac8deac720d6f8470c19bd30cb56c4de1c779abb1175f",
"md5": "2ebf1606218581e8672b0546a732e105",
"sha256": "4fcd1bb4cf20406e02c3b234984bb42158cdf9a39f9c7b00ef05381b2c1abc9c"
},
"downloads": -1,
"filename": "cs.gvutils-20230816.tar.gz",
"has_sig": false,
"md5_digest": "2ebf1606218581e8672b0546a732e105",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6246,
"upload_time": "2023-08-16T07:07:33",
"upload_time_iso_8601": "2023-08-16T07:07:33.777109Z",
"url": "https://files.pythonhosted.org/packages/d3/96/bf0a9affae4e83aac8deac720d6f8470c19bd30cb56c4de1c779abb1175f/cs.gvutils-20230816.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-16 07:07:33",
"github": false,
"gitlab": false,
"bitbucket": true,
"codeberg": false,
"bitbucket_user": "cameron_simpson",
"bitbucket_project": "css",
"lcname": "cs.gvutils"
}