本文整理汇总了Python中pydot.Dot.to_string方法的典型用法代码示例。如果您正苦于以下问题:Python Dot.to_string方法的具体用法?Python Dot.to_string怎么用?Python Dot.to_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pydot.Dot
的用法示例。
在下文中一共展示了Dot.to_string方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from pydot import Dot [as 别名]
# 或者: from pydot.Dot import to_string [as 别名]
def handle(self, filename=None, **options):
try:
from pydot import Dot, Edge, Node
except ImportError:
raise CommandError("need pydot python module ( apt-get install python-pydot )")
graph = Dot()
for status, description in STATUS_CHOICES:
graph.add_node(Node(
'status-%s' % status,
label='"%s (%s)"' %
(description.encode('utf-8'), status))
)
from sadiki.core.workflow import workflow
for transition_index in workflow.available_transitions():
transition = workflow.get_transition_by_index(transition_index)
graph.add_edge(Edge(
'status-%s'% transition.src,
'status-%s' % transition.dst,
label='"%s (%s)"' % (transition.comment.encode('utf-8'), transition.index),
style='solid' if transition.required_permissions else 'dashed',
))
if filename:
graph.write_png(filename)
else:
print graph.to_string()
示例2: TestUtilN3toDot
# 需要导入模块: from pydot import Dot [as 别名]
# 或者: from pydot.Dot import to_string [as 别名]
class TestUtilN3toDot(unittest.TestCase):
def setUp(self):
self.graph = Graph()
self.graph.parse(StringIO(n3source), format="n3")
self.dot = Dot()
def test_util_graph_to_dot(self):
res = graphutils.graph_to_dot(self.graph, self.dot)
res = self.dot.to_string()
self.assert_('swap/Primer#Person' in res, res)
示例3: main
# 需要导入模块: from pydot import Dot [as 别名]
# 或者: from pydot.Dot import to_string [as 别名]
def main():
# setup.py install/develop creates an executable that calls this function
options = parse_args(get_parser(), sys.argv[1:])
deps = list(read_file(options.input))
graph = Dot(
"Dependencies",
graph_type='digraph',
rankdir='LR',
label=sys.argv[1].split('.')[0],
fontname='Impact',
fontcolor="grey50",
fontsize=36,
)
add_nodes(graph, get_tree(deps))
add_edges(graph, deps)
print(graph.to_string())