łň jČKc@sdZddkZddklZdd d„ƒYZdefd„ƒYZedjo#ddkZeeiƒiƒndS( s9a generic command-line program to be used as a framework i˙˙˙˙N(t OptionParsert commandercBs\eZdZd ZdZd„Zd„Zd„Zd d„Z d„Z d„Z d„Z RS( s(a base class to interpret a command lines%prog 2008.06.22.0cCsZ||_td|id|iƒ|_|iƒ|iiƒ\|_|_|i ƒdS(sInitialize self.tusagetversionN( tlsLineRtsUsagetsVersiont optParsertoptionst parse_argstopttlsArgstResolveOptions(tselfR((sx/Users/amos/Documents/Database/Mental/Programming/python/lib/avatar/Personal2/www.amos/Python/lib/commander/commander.pyt__init__s   cCsdS(s2Populate the option parser with available options.N((R ((sx/Users/amos/Documents/Database/Mental/Programming/python/lib/avatar/Personal2/www.amos/Python/lib/commander/commander.pyR%scCsdS(s#Interpret the command line options.N((R ((sx/Users/amos/Documents/Database/Mental/Programming/python/lib/avatar/Personal2/www.amos/Python/lib/commander/commander.pyR )scCsdi|iƒS(s8Reproduce the command line (bug: some args need quotes).t (tjoinR(R tsName((sx/Users/amos/Documents/Database/Mental/Programming/python/lib/avatar/Personal2/www.amos/Python/lib/commander/commander.pyt__str__/scCsd|iit|iƒfS(s(Reproduce the Python instantiation call.s%s(%s)(t __class__t__name__treprR(R ((sx/Users/amos/Documents/Database/Mental/Programming/python/lib/avatar/Personal2/www.amos/Python/lib/commander/commander.pyt__repr__3scCs%x|iD]}|i|ƒq WdS(s0Pass each command line argument to self.main1().N(R tmain1(R tsArg((sx/Users/amos/Documents/Database/Mental/Programming/python/lib/avatar/Personal2/www.amos/Python/lib/commander/commander.pytmain9s cCsd| GHdS(s-Echo a command line argument on its own line.sarg: %sN((R R((sx/Users/amos/Documents/Database/Mental/Programming/python/lib/avatar/Personal2/www.amos/Python/lib/commander/commander.pyR>sN( Rt __module__t__doc__tNoneRRRRR RRRR(((sx/Users/amos/Documents/Database/Mental/Programming/python/lib/avatar/Personal2/www.amos/Python/lib/commander/commander.pyRs     t evaluatorcBs2eZdZd„Zd„Zd„Zd„ZRS(s|abstract base class for a commander that applies a function to arguments from the command line and optionally standard inputc Cs<ti|ƒ|iidddddddtdd ƒd S( s2Populate the option parser with available options.s-is--stdintactiont store_truetdesttuseStdintdefaultthelps#get additional arguments from stdinN(RRRt add_optiontFalse(R ((sx/Users/amos/Documents/Database/Mental/Programming/python/lib/avatar/Personal2/www.amos/Python/lib/commander/commander.pyRGs cCs„|io&x|iD]}|i|ƒGqWHn|iioCx@tiD]1}x'|iƒiƒD]}|i|ƒGq`WHqGWndS(s7Process the command line and optionally standard input.N(R RR R!tsyststdintstriptsplit(R RtsLine((sx/Users/amos/Documents/Database/Mental/Programming/python/lib/avatar/Personal2/www.amos/Python/lib/commander/commander.pyRQs    cCs;y|i|ƒSWn#tj o}dt|ƒSnXdS(s&Apply self.function() to the argument.sERROR: N(tfunctiont StandardErrorR(R Rtex((sx/Users/amos/Documents/Database/Mental/Programming/python/lib/avatar/Personal2/www.amos/Python/lib/commander/commander.pyR[scCstd|ii‚dS(sBDefine this to be the function you want to apply to the arguments.s %s.function()N(tNotImplementedErrorRR(R R((sx/Users/amos/Documents/Database/Mental/Programming/python/lib/avatar/Personal2/www.amos/Python/lib/commander/commander.pyR+`s(RRRRRRR+(((sx/Users/amos/Documents/Database/Mental/Programming/python/lib/avatar/Personal2/www.amos/Python/lib/commander/commander.pyRBs  t__main__(( RR&toptparseRRRRtargvR(((sx/Users/amos/Documents/Database/Mental/Programming/python/lib/avatar/Personal2/www.amos/Python/lib/commander/commander.pys s 1"