ソースを参照

Added pydot__tree_to_dot and pydot__tree_to_graph, changed pydot__tree_to_png

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.10.0
Omega16 4年前
コミット
a01de190d3
この署名に対応する既知のキーがデータベースに存在しません GPGキーID: 9DE79E7940DDDE7D
1個のファイルの変更11行の追加2行の削除
  1. +11
    -2
      lark/tree.py

+ 11
- 2
lark/tree.py ファイルの表示

@@ -160,6 +160,15 @@ class SlottedTree(Tree):


def pydot__tree_to_png(tree, filename, rankdir="LR", **kwargs):
graph = pydot__tree_to_graph(tree, rankdir, **kwargs)
graph.write_png(filename)


def pydot__tree_to_dot(tree, filename, rankdir="LR", **kwargs):
graph = pydot__tree_to_graph(tree, rankdir, **kwargs)
graph.write(filename)

def pydot__tree_to_graph(tree, rankdir="LR", **kwargs):
"""Creates a colorful image that represents the tree (data+children, without meta)

Possible values for `rankdir` are "TB", "LR", "BT", "RL", corresponding to
@@ -197,5 +206,5 @@ def pydot__tree_to_png(tree, filename, rankdir="LR", **kwargs):
return node

_to_pydot(tree)
graph.write_png(filename)
return graph

読み込み中…
キャンセル
保存