<s> __author__ = '<STR_LIT>' <EOL> import pygraphviz as pgv <EOL> import os ; <EOL> from src . tnpy import StringEntity as SE , RegexEntity as RE , TableEntity as TE , SequenceEntity as SQE , RepeatEntity as RPE , EntityBase <EOL> os . environ [ "<STR_LIT>" ] = r'<STR_LIT>' + os . environ [ "<STR_LIT>" ] ; <EOL> def addNode ( A , entity , nodes ) : <EOL> nodeid = id ( entity ) ; <EOL> name = str ( entity ) ; <EOL> if nodeid not in nodes : <EOL> A . add_node ( name ) ; <EOL> nodes [ nodeid ] = entity ; <EOL> if isinstance ( entity , SQE ) : <EOL> for child in entity . MatchEntities : <EOL> addNode ( A , child , nodes ) ; <EOL> A . add_edge ( name , str ( child ) ) ; <EOL> for child in entity . RewriteEntities : <EOL> addNode ( A , child , nodes ) ; <EOL> A . add_edge ( name , str ( child ) ) ; <EOL> elif isinstance ( entity , TE ) : <EOL> for child in entity . Tables : <EOL> addNode ( A , child , nodes ) ; <EOL> A . add_edge ( name , str ( child ) ) ; <EOL> A . add_node ( entity ) <EOL> def buildGraph ( tn , entityname ) : <EOL> A = pgv . AGraph ( directed = True , strict = True ) <EOL> entities = tn . Entities ; <EOL> entity = entities [ entityname ] ; <EOL> nodes = { } ; <EOL> addNode ( A , entity , nodes ) ; <EOL> A . graph_attr [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> print ( A . string ( ) ) <EOL> A . write ( '<STR_LIT>' ) <EOL> A . layout ( '<STR_LIT>' ) <EOL> A . draw ( '<STR_LIT>' ) </s>
