entity_query_language.utils#

Attributes#

Classes#

IDGenerator

A class that generates incrementing, unique IDs and caches them for every object this is called on.

FilteredDotExporter

ALL

Sentinel that compares equal to any other value.

Functions#

lazy_iterate_dicts(dict_of_iterables)

Generator that yields dicts with one value from each iterable

generate_combinations(generators_dict)

Yield all combinations of generator values as keyword arguments

filter_data(data, selected_indices)

make_list(→ typing_extensions.List)

Make a list from a value.

is_iterable(→ bool)

Check if an object is iterable.

make_tuple(→ typing_extensions.Any)

Make a tuple from a value.

make_set(→ typing_extensions.Set)

Make a set from a value.

get_unique_node_names_func(...)

edge_attr_setter(parent, child)

Set the edge attributes for the dot exporter.

render_tree(→ None)

Render the tree/graph using console and optionally export it to an image file.

Module Contents#

entity_query_language.utils.six = None#
entity_query_language.utils.Source = None#
class entity_query_language.utils.IDGenerator#

A class that generates incrementing, unique IDs and caches them for every object this is called on.

entity_query_language.utils.lazy_iterate_dicts(dict_of_iterables)#

Generator that yields dicts with one value from each iterable

entity_query_language.utils.generate_combinations(generators_dict)#

Yield all combinations of generator values as keyword arguments

entity_query_language.utils.filter_data(data, selected_indices)#
entity_query_language.utils.make_list(value: typing_extensions.Any) typing_extensions.List#

Make a list from a value.

Parameters:

value – The value to make a list from.

entity_query_language.utils.is_iterable(obj: typing_extensions.Any) bool#

Check if an object is iterable.

Parameters:

obj – The object to check.

entity_query_language.utils.make_tuple(value: typing_extensions.Any) typing_extensions.Any#

Make a tuple from a value.

entity_query_language.utils.make_set(value: typing_extensions.Any) typing_extensions.Set#

Make a set from a value.

Parameters:

value – The value to make a set from.

entity_query_language.utils.get_unique_node_names_func(root_node) typing_extensions.Callable[[anytree.Node], str]#
entity_query_language.utils.edge_attr_setter(parent, child)#

Set the edge attributes for the dot exporter.

class entity_query_language.utils.FilteredDotExporter(node, include_nodes=None, graph='digraph', name='tree', options=None, indent=4, nodenamefunc=None, nodeattrfunc=None, edgeattrfunc=None, edgetypefunc=None, maxlevel=None)#

Bases: object

node#
graph = 'digraph'#
name = 'tree'#
options = None#
indent = 4#
nodenamefunc = None#
nodeattrfunc = None#
edgeattrfunc = None#
edgetypefunc = None#
maxlevel = None#
include_nodes = None#
include_node_names = None#
to_dotfile(filename)#

Write graph to filename.

>>> from anytree import Node
>>> root = Node("root")
>>> s0 = Node("sub0", parent=root)
>>> s0b = Node("sub0B", parent=s0)
>>> s0a = Node("sub0A", parent=s0)
>>> s1 = Node("sub1", parent=root)
>>> s1a = Node("sub1A", parent=s1)
>>> s1b = Node("sub1B", parent=s1)
>>> s1c = Node("sub1C", parent=s1)
>>> s1ca = Node("sub1Ca", parent=s1c)
>>> from anytree.exporter import DotExporter
>>> DotExporter(root).to_dotfile("tree.dot")

The generated file should be handed over to the dot tool from the http://www.graphviz.org/ package:

$ dot tree.dot -T png -o tree.png
to_picture(filename)#

Write graph to a temporary file and invoke dot.

The output file type is automatically detected from the file suffix.

`graphviz` needs to be installed, before usage of this method.

to_source() graphviz.Source#

Return the source code of the graph as a Source object.

static esc(value)#

Escape Strings.

entity_query_language.utils.render_tree(root: anytree.Node, use_dot_exporter: bool = False, filename: str = 'query_tree', only_nodes: typing_extensions.List[anytree.Node] = None, show_in_console: bool = False, color_map: typing_extensions.Optional[typing_extensions.Callable[[anytree.Node], str]] = None, view: bool = False, layout_engine: str = 'dot', render_backend: str = 'graphviz') None#

Render the tree/graph using console and optionally export it to an image file.

Parameters:
  • root – The root node of the tree/graph.

  • use_dot_exporter – Whether to export using Graphviz/DOT (kept for backward-compat with anytree).

  • filename – The base file name for output files (without extension).

  • only_nodes – Limit export to these nodes (anytree only).

  • show_in_console – Whether to print a textual representation.

  • color_map – Function mapping a node to a color string.

  • view – Whether to open a viewer after generating (graphviz backend only).

  • layout_engine – Layout name. For graphviz: “dot”, “neato”, etc. For igraph: “tree”, “kk”, “fr”, “sugiyama”.

  • render_backend – “graphviz” (default) or “igraph” for python-igraph.

class entity_query_language.utils.ALL#

Sentinel that compares equal to any other value.

This is used to signal wildcard matches in hashing/containment logic.

entity_query_language.utils.All#