<s> """<STR_LIT>""" <EOL> try : <EOL> import json <EOL> except : <EOL> try : <EOL> import simplejson as json <EOL> except ImportError : <EOL> from sys import exc_info <EOL> ex_type , ex_value , tb = exc_info ( ) <EOL> new_ex = Exception ( "<STR_LIT>" % ( ex_type . __name__ , ex_value ) ) <EOL> raise new_ex . __class__ , new_ex , tb <EOL> from optparse import OptionParser <EOL> import sys <EOL> from pystache . common import TemplateNotFoundError <EOL> from pystache . renderer import Renderer <EOL> USAGE = """<STR_LIT>""" <EOL> def parse_args ( sys_argv , usage ) : <EOL> """<STR_LIT>""" <EOL> args = sys_argv [ <NUM_LIT:1> : ] <EOL> parser = OptionParser ( usage = usage ) <EOL> options , args = parser . parse_args ( args ) <EOL> template , context = args <EOL> return template , context <EOL> def main ( sys_argv = sys . argv ) : <EOL> template , context = parse_args ( sys_argv , USAGE ) <EOL> if template . endswith ( '<STR_LIT>' ) : <EOL> template = template [ : - <NUM_LIT:9> ] <EOL> renderer = Renderer ( ) <EOL> try : <EOL> template = renderer . load_template ( template ) <EOL> except TemplateNotFoundError : <EOL> pass <EOL> try : <EOL> context = json . load ( open ( context ) ) <EOL> except IOError : <EOL> context = json . loads ( context ) <EOL> rendered = renderer . render ( template , context ) <EOL> print rendered <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
