<s> from structs import Operation <EOL> import json <EOL> class PrintOperation ( Operation ) : <EOL> """<STR_LIT>""" <EOL> def perform ( self , obj ) : <EOL> print obj <EOL> class FileOutputOperation ( Operation ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , filename ) : <EOL> self . output = open ( filename , '<STR_LIT:w>' ) <EOL> def perform ( self , obj ) : <EOL> self . output . write ( obj + '<STR_LIT:\n>' ) <EOL> def __del__ ( self ) : <EOL> self . output . flush ( ) <EOL> self . output . close ( ) <EOL> class JSONFileOutputOperation ( FileOutputOperation ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , filename ) : <EOL> super ( JSONFileOutputOperation , self ) . __init__ ( filename ) <EOL> def perform ( self , obj ) : <EOL> self . output . write ( json . dumps ( obj ) + '<STR_LIT:\n>' ) <EOL> def __del__ ( self ) : <EOL> super ( JSONFileOutputOperation , self ) . __del__ ( ) </s>
