<s> """<STR_LIT>""" <EOL> from __future__ import unicode_literals <EOL> import codecs <EOL> def export_to_dot ( tree , filename , shape = '<STR_LIT>' , graph = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> nodes , connections = [ ] , [ ] <EOL> if tree . nodes : <EOL> for n in tree . expand_tree ( mode = tree . WIDTH ) : <EOL> nid = tree [ n ] . identifier <EOL> state = '<STR_LIT:">' + nid + '<STR_LIT:">' + '<STR_LIT>' + tree [ n ] . tag + '<STR_LIT>' + shape + '<STR_LIT:]>' <EOL> nodes . append ( state ) <EOL> for c in tree . children ( nid ) : <EOL> cid = c . identifier <EOL> connections . append ( '<STR_LIT:">' + nid + '<STR_LIT:">' + '<STR_LIT>' + '<STR_LIT:">' + cid + '<STR_LIT:">' ) <EOL> with codecs . open ( filename , '<STR_LIT:w>' , '<STR_LIT:utf-8>' ) as f : <EOL> f . write ( graph + '<STR_LIT>' ) <EOL> for n in nodes : <EOL> f . write ( '<STR_LIT:\t>' + n + '<STR_LIT:\n>' ) <EOL> f . write ( '<STR_LIT:\n>' ) <EOL> for c in connections : <EOL> f . write ( '<STR_LIT:\t>' + c + '<STR_LIT:\n>' ) <EOL> f . write ( '<STR_LIT:}>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> pass </s>
