<s> """<STR_LIT>""" <EOL> __author__ = "<STR_LIT>" <EOL> __revision__ = "<STR_LIT>" [ <NUM_LIT:11> : - <NUM_LIT:2> ] <EOL> import sys <EOL> import os <EOL> import getopt <EOL> import os . path <EOL> try : <EOL> from cPickle import load <EOL> except ImportError : <EOL> from pickle import load <EOL> from Cheetah . Version import Version <EOL> class Error ( Exception ) : <EOL> pass <EOL> class CmdLineIface : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , templateObj , <EOL> scriptName = os . path . basename ( sys . argv [ <NUM_LIT:0> ] ) , <EOL> cmdLineArgs = sys . argv [ <NUM_LIT:1> : ] ) : <EOL> self . _template = templateObj <EOL> self . _scriptName = scriptName <EOL> self . _cmdLineArgs = cmdLineArgs <EOL> def run ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _processCmdLineArgs ( ) <EOL> print ( self . _template ) <EOL> def _processCmdLineArgs ( self ) : <EOL> try : <EOL> self . _opts , self . _args = getopt . getopt ( <EOL> self . _cmdLineArgs , '<STR_LIT:h>' , [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] ) <EOL> except getopt . GetoptError , v : <EOL> print ( v ) <EOL> print ( self . usage ( ) ) <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> for o , a in self . _opts : <EOL> if o in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> print ( self . usage ( ) ) <EOL> sys . exit ( ) <EOL> if o == '<STR_LIT>' : <EOL> self . _template . searchList ( ) . insert ( <NUM_LIT:0> , os . environ ) <EOL> if o == '<STR_LIT>' : <EOL> if a == '<STR_LIT:->' : <EOL> unpickled = load ( sys . stdin ) <EOL> self . _template . searchList ( ) . insert ( <NUM_LIT:0> , unpickled ) <EOL> else : <EOL> f = open ( a ) <EOL> unpickled = load ( f ) <EOL> f . close ( ) <EOL> self . _template . searchList ( ) . insert ( <NUM_LIT:0> , unpickled ) <EOL> def usage ( self ) : <EOL> return """<STR_LIT>""" % { '<STR_LIT>' : self . _scriptName , <EOL> '<STR_LIT>' : Version , <EOL> } </s>
