<s> """<STR_LIT>""" <EOL> from os . path import splitext <EOL> from re import escape <EOL> DEFAULT = '<STR_LIT:#>' <EOL> TABLE = { <EOL> '<STR_LIT>' : '<STR_LIT:#>' , <EOL> '<STR_LIT>' : '<STR_LIT:#>' , <EOL> '<STR_LIT:c>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> def add_inline_comment ( area ) : <EOL> """<STR_LIT>""" <EOL> comment = TABLE . get ( splitext ( area . filename ) [ <NUM_LIT:1> ] , DEFAULT ) <EOL> def rep ( index0 , index1 ) : <EOL> return '<STR_LIT>' % ( area . get ( index0 , index1 ) , comment ) <EOL> area . replace_ranges ( '<STR_LIT>' , '<STR_LIT>' , rep ) <EOL> area . clear_selection ( ) <EOL> def rm_inline_comment ( area ) : <EOL> """<STR_LIT>""" <EOL> comment = TABLE . get ( splitext ( area . filename ) [ <NUM_LIT:1> ] , DEFAULT ) <EOL> def rep ( index0 , index1 ) : <EOL> chk = area . get ( index0 , index1 ) <EOL> chk = chk . replace ( '<STR_LIT>' % comment , '<STR_LIT>' ) <EOL> chk = chk . replace ( comment , '<STR_LIT>' ) <EOL> return chk <EOL> area . replace_ranges ( '<STR_LIT>' , '<STR_LIT>' % comment , rep ) <EOL> area . clear_selection ( ) <EOL> def install ( area ) : <EOL> area . install ( ( '<STR_LIT>' , '<STR_LIT>' , lambda event : rm_inline_comment ( event . widget ) ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , lambda event : add_inline_comment ( event . widget ) ) ) </s>
