<s> import os <EOL> from pycket . expand import expand_string , readfile <EOL> def write_to_file ( expanded , targetfile ) : <EOL> try : <EOL> os . remove ( targetfile ) <EOL> except IOError : <EOL> pass <EOL> except OSError : <EOL> pass <EOL> f = open ( targetfile , "<STR_LIT:w>" ) <EOL> f . write ( str ( expanded ) ) <EOL> f . close ( ) <EOL> def load_expanded ( fname ) : <EOL> stdlib = readfile ( "<STR_LIT>" ) <EOL> s = readfile ( fname ) <EOL> code = "<STR_LIT>" % ( stdlib , s ) <EOL> return expand_string ( code ) <EOL> def main ( argv ) : <EOL> if not ( len ( argv ) == <NUM_LIT:3> ) : <EOL> print "<STR_LIT>" <EOL> return <NUM_LIT:1> <EOL> source = argv [ <NUM_LIT:1> ] <EOL> target = argv [ <NUM_LIT:2> ] <EOL> code = load_expanded ( source ) <EOL> write_to_file ( code , target ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import sys <EOL> main ( sys . argv ) </s>
