Ic@s$ddkZddkZddkZddkZddkZddkZddkZddkZddkZddk Z yddk Z Wn#e j oddk l Z nXeaeiddfjoddklZnddklZdefdYZdefd YZeid Zeiid iZeid ed deei efddZ!e!i"ddddddde!i"dddddddde!i#gZ$edZ%dZ&dZ'd Z(d!efd"YZ)d#e)fd$YZ*ed%Z+dS(&iN(t subprocess24ii(t fileConfigt BadCommandcBseZddZRS(icCs&||_||_ti||dS(N(tmessaget exit_codet Exceptiont__init__(tselfRR((s8/usr/lib/python2.6/site-packages/paste/script/command.pyRs  (t__name__t __module__R(((s8/usr/lib/python2.6/site-packages/paste/script/command.pyRst NoDefaultcBseZRS((RR (((s8/usr/lib/python2.6/site-packages/paste/script/command.pyR !st PasteScriptitadd_help_optiontversions%s from %s (python %s)tusages0%prog [paster_options] COMMAND [command_options]s--plugintactiontappendtdesttpluginsthelpsYAdd a plugin to the list of commands (plugins are Egg specs; will also require() the Egg)s-hs--helpt store_truetdo_helpsShow this help messagecCsp| ottidjoktiidoXtidtidjo=tidtidjo"dtidgtid}n|djotid}nti|\}}t|_ t i |i pgt }|iodg|}n|pdtidGHdg}n|d}||jo t}n||i}t||||ddS(Nit_iitexeRsUsage: %s COMMAND(tlentsystargvtostenvirontgettNonetparsert parse_argst base_parsertsystem_pluginstextendRt get_commandsRtNotFoundCommandtloadtinvoke(targstoptionstcommandst command_nametcommand((s8/usr/lib/python2.6/site-packages/paste/script/command.pytrun=s*."        c CsQddk}ti}|i|gd}g}|iddo|idd}n|iddo|i|idd}n|iddo|i|idd}g}|D]4}|tii tii tii ||q~}x5|D])}t i i|tiid|q Wn||g|}|S(NiRR,R)ssys.pathi(tshlext ConfigParsertRawConfigParsertreadt has_optionRtsplitRtpathtabspathtjointdirnamet pkg_resourcest working_sett add_entryRtinsert( tconfigR.tpR+R)tpathst_[1]R4R(((s8/usr/lib/python2.6/site-packages/paste/script/command.pytparse_exe_fileVs&  AcCst}titi}|ov|itiitii|dtii |}|t ijo't ii d|t i i|qnti|}ti|}|iti|S(Ni(R"t pluginlibtfind_egg_info_dirRtgetcwdRR4tsplitexttbasenameR7RR;R8R9R:tresolve_pluginstload_commands_from_pluginstupdatetload_global_commands(Rt egg_info_dirtbase_dirR*((s8/usr/lib/python2.6/site-packages/paste/script/command.pyR$js)cCsYy||}|i|}Wn&tj o}|iGH|i}nXti|dS(N(R-RRRRtexit(R,R+R)R(trunnerRte((s8/usr/lib/python2.6/site-packages/paste/script/command.pyR'xs tCommandcBs|eZdZdZdZdZdZdZdZ dZ dZdZ dZ e ZdZdZdZeZdZdZdZeeZe edZeed Zd d Zee e e e e d ZeeZd ZedZedZe dZ dZ!dZ"e Z#dZ$deedZ%dZ&ddZ'ddZ(dddZ)dZ*RS(cCs ||_dS(N(R+(Rtname((s8/usr/lib/python2.6/site-packages/paste/script/command.pyRss4You must provide no more than %(max_args)s argumentss0You must provide at least %(min_args)s argumentstic Cs$|i|xVdddtfdtfgD]6\}}t|i|pt|i||q,q,Wt|idtot|iid|i_n|i|_ t|idto|i |ii 7_ nt|idto t|_ n|i |_|i|ii7_|i|ii 8_t|idt|_ t iid o|idj oy|i}t iid }|djo|iid|q|d jo|ii|qdptd |nt iid o d|_n|idj oJt|i|ijo1t|ih|id 6t|id6n|idj oJt|i|ijo1t|ih|id6t|id6nxA|iD]6\}}t|i|dptd|qqW|i}|djo|iS|SdS(Ntverboseitquiett interactivet overwritetsimulateitno_interactivetPASTE_CONFIG_FILEis7Value takes_config_file must be None, 1, or -1 (not %r)tPASTE_DEFAULT_QUIETtmin_argst actual_argstmax_argssYou must provide the option %s(sverbosei(squieti(R tFalsethasattrR)tsetattrtgetattrtmaxRRtdefault_interactiveRTtdefault_verbosityRSRVRRRttakes_config_fileRR(R;RtAssertionErrorRZRRtmin_args_errorR\tmax_args_errort required_argsR,t return_code( RR(RPtdefaultttaketfilenametvar_namet option_nametresult((s8/usr/lib/python2.6/site-packages/paste/script/command.pyR-sb            ))   cCs|iod|i}nd}d||if|i_dtid|if|i_|io(|i}ti |}||i_n|ii |\|_ |_ dS(Nt RQs%%prog [options]%s %ss%s %si( RtsummaryRRRR+tprogt descriptionttextwraptdedentR R)R((RR(Rtdesc((s8/usr/lib/python2.6/site-packages/paste/script/command.pyR s    cCs#ti|i}tii|iS(N(RtmodulesR RR4R7t__file__(tclstmod((s8/usr/lib/python2.6/site-packages/paste/script/command.pytherescCs|iidjo |}n|djo|d7}n;|djo|d7}n |o|d7}n |d7}xt|ii}|p|djo dGHqun|S|djo$|djo |d jSd GHqun|d idjo|d id jSdGHqudS(sx Prompt the user. Default can be true, false, ``'careful'`` or ``'none'``. If ``'none'`` then the user must enter y/n. If ``'careful'`` then the user must enter yes/no (long form). If the interactive option is over two (``-ii``) then ``safe`` will be used as a default. This option should be the do-nothing option. itcarefuls [yes/no]?tnones [y/n]?s [Y/n]? s [y/N]? sPlease enter yes or notyestnosPlease enter "yes" or "no"itytns Y or N pleaseN(R|R}(R~R(RR(R)RTt raw_inputtstriptlower(RtprompttsafeRjtresponse((s8/usr/lib/python2.6/site-packages/paste/script/command.pytasks0         cCs|tj o|d|7}n|d7}xS|o t}n ti}||i}|p|tj o|Sq,q,|Sq,dS(s1 Prompt the user for a variable. s [%r]s: N(R RtgetpassR(RRRjt should_echot prompt_methodR((s8/usr/lib/python2.6/site-packages/paste/script/command.pyt challenges     tleftcCsVt||jo|S|djo|d|t|Sd|t||SdS(NRRp(R(Rtstlengthtdir((s8/usr/lib/python2.6/site-packages/paste/script/command.pytpad3s  c Csti}|o&|iddddddddn|o&|id d dddd ddn|o#|id dddd ddn|o&|iddddddddn|o&|idddddddtn|o&|iddddddddn|S(s+ Create a standard ``OptionParser`` instance. Typically used like:: class MyCommand(Command): parser = Command.standard_parser() Subclasses may redefine ``standard_parser``, so use the nearest superclass's class method. s-vs --verboseRtcountRRRRjis-qs--quietRSs--no-interactiveRWs-is --interactiveRTs-ns --simulateRRVs-fs --overwriteRURsKOverwrite files (warnings will be emitted for non-matching files otherwise)(t bool_optparsetBoolOptionParsert add_optionR](RyRRRTRWRVRSRUR((s8/usr/lib/python2.6/site-packages/paste/script/command.pytstandard_parser;s@        cGsb|otii||}n|itio$|ttiitiiS|SdS(s Return a shorted form of the filename (relative to the current directory), typically for displaying in messages. If ``*paths`` are present, then use os.path.join to create the full filename before shortening. N(RR4R6t startswithRCRtlstriptsep(RtfnR>((s8/usr/lib/python2.6/site-packages/paste/script/command.pytshortenos $cCs|iti}|pdStii|p|itii||iod|i|GHn|i pti |n|oBtiitii tii|do|i d|qn'|idjod|i|GHndS(s Ensure that the directory exists, creating it if necessary. Respects verbosity and simulation. Adds directory to subversion if ``.svn/`` directory exists in parent, and directory was created. Ns Creating %ss.svntaddisDirectory already exists: %s( trstripRRR4texistst ensure_dirR7RRRRVtmkdirR6t svn_command(RRtsvn_add((s8/usr/lib/python2.6/site-packages/paste/script/command.pyR}s  .cCsh|dj p td|itii|d|tii|p|io d|GHn|ip*t |d}|i ||i n|oHtiitii tii|do|i d|dtndSt |d }|i}|i ||jo"|id jo d |GHndS|iipd |GHtdjod dkanti|i|id||}di |GH|iobxctdii}|p d}n|idoPn|idodSdGHqqdSn|io d|GHn|ip*t |d}|i ||i ndS(s Ensure a file named ``filename`` exists with the given content. If ``--interactive`` has been enabled, this will ask the user what to do if a file exists with different content. s!You cannot pass a content of NoneRs Creating %stwbs.svnRtwarn_returncodeNtrbis File %s matches expected contents0Warning: file %s does not match expected contentis expected s s'Overwrite file with new content? [y/N] RRsUnknown response; Y or N pleasesOverwriting %s with new content(RReRRR4R7RRRRVtopentwritetcloseR6RtTrueR1R)RUtdifflibt context_difft splitlinesRTRRRR(RRltcontentRtft old_contenttdiffR((s8/usr/lib/python2.6/site-packages/paste/script/command.pyt ensure_filesb    5                  c Cs>|idptd|ntii| o/|io%|iod|i|GHndSt|}|i }|i t i dt i |t i}x/tt|D]}|i||o||o_t||djoHdi||dii|iod|GHd ||GHdS|o9|i}t id ||} | id |}n|g||d|d+PqqWd ||f} dp |io d | GHn t| |iod|i|GHn|ip3t|d}|idi||i ndS(sl Inserts ``text`` into the file, right after the given marker. Markers look like: ``-*- [:]? -*-``, and the text will go on the immediately following line. Raises ``ValueError`` if the marker is not found. If ``indent`` is true, then the text will be indented at the same level as the marker. s s$The text must end with a newline: %rs-Would (if not simulating) insert text into %sNs-\*-\s+%s:?\s+-\*-iRQs0Warning: line already found in %s (not insertings %ss^[ \t]*is#Marker '-*- %s -*-' not found in %ss Warning: %ss Updating %stw(tendswitht ValueErrorRR4RRVRRRRt readlinesRtretcompiletescapetItrangeRtsearchR6RRRtgroupR( RRlt marker_namettexttindentRtlinestregextitmatchterrstr((s8/usr/lib/python2.6/site-packages/paste/script/command.pytinsert_into_filesL      "-         c Osn|i|}t|dti}t|dt}t|dt}t|dt}t|dt}|o t}n|i} |o t} n| ptd||o ti } n ti } y5ti |gt |d|d| dti } WnBt j o6} | id jont d || fnX|iod |d i|fGHn| odS| i\} }| io^| oV|ipd |d i|fGHnd | iGH|o |GHnt d|n|id jo.|odGH|GHn| odGH| GHqjn:| io/|o(d|d i|fGHd| iGHn| S(s Runs the command, respecting verbosity and simulation. Returns stdout, or None if simulating. Keyword arguments: cwd: the current working directory to run the command in capture_stderr: if true, then both stdout and stderr will be returned expect_returncode: if true, then don't fail if the return code is not 0 force_no_simulate: if true, run the command even if --simulate tcwdtcapture_stderrtexpect_returncodetforce_no_simulateRsArguments not expected: %ststderrtstdoutis-The expected executable %s was not found (%s)s Running %s %sRpsError (exit code: %s)sError executing command %ssCommand error output:sCommand output:sWarning: command failed (%s %s)sExited with code %sN(tquote_first_command_argt popdefaultRRCR]RRVRet subprocesstSTDOUTtPIPEtPopentlisttOSErrorterrnoRRR6Rt communicatet returncode(RtcmdR(tkwRRRtforceRRVt stderr_pipetprocRNRR((s8/usr/lib/python2.6/site-packages/paste/script/command.pyt run_commandsb           cCsktidjp d|jo|Syddk}Wn#tj otd|nX|i|}|S(s  There's a bug in Windows when running an executable that's located inside a path with a space in it. This method handles that case, or on non-Windows systems or an executable with no spaces, it just leaves well enough alone. twin32RpiNsqThe executable %r contains a space, and in order to handle this issue you must have the win32api module installed(Rtplatformtwin32apit ImportErrorRtGetShortPathName(RtargR((s8/usr/lib/python2.6/site-packages/paste/script/command.pyRTs cOsSy|id||SWn5tj o)}|ipd|GHt|_qOnXdS(sO Run an svn command, but don't raise an exception if it fails. tsvns1Unable to run svn command (%s); proceeding anywayN(RRt _svn_failedR(RR(RRN((s8/usr/lib/python2.6/site-packages/paste/script/command.pyRks   c Csddk}|idtdtii|o|ot|d}nt|d}|i}|i||jo%|i od|i |GHndS|i o*|i i o|id|pdSqn|i d jo,|o%d |i ||i |fGHn!|i od |i |GHn|i ptii|} |ot|d }nt|d }|i||i| oI|oBtiitiitii|do|id|qndS(s Like ``ensure_file``, but without the interactivity. Mostly deprecated. (I think I forgot it existed) iNs=command.write_file has been replaced with command.ensure_fileiRtrs File %s exists with same contentsOverwrite file %s?isWriting %s from %ss Writing %sRRs.svnR(twarningstwarntDeprecationWarningRR4RRR1RRRRRVR)RTRRR6R7R( RRlRtsourcetbinaryRRRRtalready_existed((s8/usr/lib/python2.6/site-packages/paste/script/command.pyt write_filevsD           .cCs^h}xQ|D]I}d|jotd|n|idd\}}|||s\                 w