Ñò ›ˆQc@sÓdZddkZddkZddkZddkZddkZddkZddkZddkZddk Z ddk Z e i Z e i dddƒe i dddƒe i ded ƒgZeZd efd „ƒYZd efd „ƒYZde ifd„ƒYZde ifd„ƒYZde ifd„ƒYZde ifd„ƒYZd„Zead„Zd„Zdd„Zd„Z d„Z!ddddd„Z"de#fd„ƒYZ$d„Z%dS( s…Generic entry point for Google applications. To use this module, simply define a 'main' function with a single 'argv' argument and add the following to the end of your source file: if __name__ == '__main__': app.run() TODO(user): Remove silly main-detection logic, and force all clients of this module to check __name__ explicitly. Fix all current clients that don't check __name__. iÿÿÿÿNt run_with_pdbisSet to true for PDB debug modetrun_with_profilingsmSet to true for profiling the script. Execution will be slower, and the output format might change over time.tuse_cprofile_for_profilingspUse cProfile instead of the profile module for profiling. This has no effect unless --run_with_profiling is set.tErrorcBseZRS((t__name__t __module__(((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyR9st UsageErrorcBseZdZdd„ZRS(s{The arguments supplied by the user are invalid. Raise this when the arguments supplied are invalid from the point of view of the application. For example when two mutually exclusive flags have been supplied or when there are not enough non-flag arguments. It is distinct from flags.FlagsError which covers the lower level of parsing and validating individual flags. icCsti||ƒ||_dS(N(Rt__init__texitcode(tselftmessageR((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyRGs(RRt__doc__R(((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyR=stHelpFlagcBs eZdZd„Zd„ZRS(s?Special boolean flag that displays usage and raises SystemExit.c Cs)tii|dddddddƒdS(Nthelpisshow this helpt short_namet?tallow_overridei(tflagst BooleanFlagR(R ((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyROscCs)|otddƒtidƒndS(Ntwriteto_stdouti(tusagetsystexit(R targ((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pytParseSs (RRR RR(((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyR Ls t HelpXMLFlagcBs eZdZd„Zd„ZRS(s8Similar to HelpFlag, but generates output in XML format.cCs#tii|dtdddƒdS(Nthelpxmls%like --help, but generates XML outputRi(RRRtFalse(R ((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyR\scCs/|o$tiitiƒtidƒndS(Ni(RtFLAGStWriteHelpInXMLFormatRtstdoutR(R R((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyRas(RRR RR(((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyRYs t HelpshortFlagcBs eZdZd„Zd„ZRS(sFSpecial bool flag that calls usage(shorthelp=1) and raises SystemExit.cCs#tii|dddddƒdS(Nt helpshortisshow usage only for this moduleRi(RRR(R ((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyRjscCs/|o$tddddƒtidƒndS(Nt shorthelpiR(RRR(R R((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyRos(RRR RR(((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyRgs t BuildDataFlagcBs eZdZd„Zd„ZRS(s8Boolean flag that writes build data to stdout and exits.cCstii|dddƒdS(Ntshow_build_dataisshow build data and exit(RRR(R ((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyRyscCs2|o'tiitiƒƒtidƒndS(Ni(RRtwritet build_datat BuildDataR(R R((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyR}s(RRR RR(((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyR"us cCsdyt|ƒ}|SWnItij o:}tiid|ƒtiidƒtidƒnXdS(sATry parsing the flags, printing usage and exiting if unparseable.sFATAL Flags parsing error: %s s1Pass --help or --helpshort to see help on flags. iN(RRt FlagsErrorRtstderrR$R(targstargvterror((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pytparse_flags_with_usageƒs cCsUtpJtitƒƒtitƒƒtitƒƒtitƒƒtandS(s Register help flags. Idempotent.N(t_define_help_flags_calledRt DEFINE_flagR RRR"tTrue(((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pytDefineHelpFlags‘s cCstƒttiƒ}|S(s~Register help flags, parse arguments and show usage if appropriate. Returns: remaining arguments after flags parsing (R0R,RR*(R*((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pytRegisterAndParseFlagsWithUsageŸscCstƒ}|djotidi}ny¹tiotiti ||ƒƒnti oqddk }ti oddk }n ddk}|iƒ}|i|iƒ|i ||ƒ}ti|ƒnti||ƒƒWn1tj o%}tddd|d|iƒnXdS(s=Initializes flag values, and calls main with non-flag arguments. Only non-flag arguments are passed to main(). The return value of main() is used as the exit status. Args: main: Main function to run with the list of non-flag arguments, or None so that sys.modules['__main__'].main is to be used. t__main__iÿÿÿÿNR!itdetailed_errorR(R1tNoneRtmodulestmainRRRtpdbtruncallRtatexitRtcProfiletprofiletProfiletregistert print_statsRRR(R6R*R9R;tprofilertretvalR+((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyt really_start«s$        cCstƒS(sõBegin executing the program. - Parses command line flags with the flag module. - If there are any errors, print usage(). - Calls main() with the remaining arguments. - If main() raises a UsageError, print usage and the error message. (t _actual_start(((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pytrunÐsc CsDd}ytdƒ‚Wn#tj otiƒd}nX|pt‚|iii}|pdS|iiddƒ}|djo|i dƒ odS~ti ƒy t ƒWnˆt j o }‚nrt j oe}xVtD]N}y%|i|ƒo|i|ƒnWqætiitiƒƒ‚qæXqæW‚nXdS(s$Another layer in the starting stack.tiNRR2s .appcommands(R4tZeroDivisionErrorRtexc_infotAssertionErrorttb_frametf_backt f_globalstgettendswitht exc_clearRAt SystemExitt ExceptiontEXCEPTION_HANDLERStWantstHandleR(R$t tracebackt format_exc(ttbtprev_prev_frametprev_prev_nametethandler((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyRBÛs:    c Cs¾|o ti}n ti}tidi}|p0dtid}ti|ddddƒ}n|idƒd |id ƒ}y|tidf|;}Wnt t t fj onXt otiti |ƒƒ}n|otiƒ}n ttƒ}ye|i|ƒ|o|id ƒ|i|ƒn|id ƒ|dj o|id |ƒnWn/tj o#}|itijo‚qœnX|dj oti|ƒndS(sfWrite __main__'s docstring to stderr with some help text. Args: shorthelp: print only flags from this module, rather than all flags. writeto_stdout: write help message to stdout, rather than to stderr. detailed_error: additional detail about why usage info was presented. exitcode: if set, exit with this status code after writing help. R2s USAGE: %s [flags] itindents tfirstline_indentRDt%is%%s flags: s s %s N(RRR(R5R R*RtTextWraptcountt OverflowErrort TypeErrort ValueErrorthelp_text_wrapt DocToHelpRtMainModuleHelptstrR$R4tIOErrorterrnotEPIPER( R!RR3Rtstdfiletdoctnum_specifierstflag_strRX((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyRs<           tExceptionHandlercBs eZdZd„Zd„ZRS(s4Base exception handler from which other may inherit.cCstS(sCheck if this exception handler want to handle this exception. Args: unused_exc: Exception, the current exception Returns: boolean This base handler wants to handle all exceptions, override this method if you want to be more selective. (R/(R t unused_exc((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyRQ;s cCs tƒ‚dS(s‰Do something with the current exception. Args: exc: Exception, the current exception This method must be overridden. N(tNotImplementedError(R texc((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyRRIs(RRR RQRR(((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pyRm8s cCs;t|tƒptdt|ƒƒ‚nti|ƒdS(saInstall an exception handler. Args: handler: an object conforming to the interface defined in ExceptionHandler Raises: TypeError: handler was not of the correct type All installed exception handlers will be called if main() exits via an abnormal exception, i.e. not one of SystemExit, KeyboardInterrupt, FlagsError or UsageError. s9handler of type %s does not inherit from ExceptionHandlerN(t isinstanceRmR`ttypeRPtappend(RY((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pytInstallExceptionHandlerTs (&R RgtosR7tsockettstattstructRttimeRStgflagsRRtDEFINE_booleanR/RPRRbRORRRR RRR"R,R-R0R1R4RARCRBRtobjectRmRt(((s[/Users/riccardo/git/gcloud/packages/gcutil-1.7.1/lib/google_apputils/google/apputils/app.pytsD                 % ,1