Ñò ‚Ic @s¬ddkZddkZddkZddklZlZddklZea yddk Z Wn#e j oddk l Z nXdefd„ƒYZed„ZdS(iÿÿÿÿN(t pluginlibtcopydir(t BadCommand(t subprocess24tFileOpcBsªeZdZeeed d d„Zd eed d„Zd ed„Zd d„Z ed„Z d„Z eed„Z eed„Z d „ZeZd „Zd „ZRS( s^ Enhance the ease of file copying/processing from a package into a target project cCsZ||_||_||_|djo h}n||_||_t|tƒ|_dS(s Initialize our File operation helper object source_dir Should refer to the directory within the package that contains the templates to be used for the other copy operations. It is assumed that packages will keep all their templates under a hierarchy starting here. This should be an absolute path passed in, for example:: FileOp(source_dir=os.path.dirname(__file__) + '/templates') N( tsimulatetverboset interactivetNonet template_varst source_dirt isinstancettupletuse_pkg_resources(tselfRRRR R ((s:/usr/lib/python2.6/site-packages/paste/script/filemaker.pyt__init__s       c CsÀ|p5|idƒd}|idƒo|d }q<n|i||ƒ\}}||id<|i||||d|ƒ} |od|}ntii||ƒ}|i|| |ƒdS( sô Copy a file from the source location to somewhere in the destination. template The filename underneath self.source_dir to copy/process dest The destination directory in the project relative to where this command is being run filename What to name the file in the target project, use the same name as the template if not provided add_py Add a .py extension to all files copied package Whether or not this file is part of a Python package, and any directories created should contain a __init__.py file as well. template_renderer An optional template renderer t/it_tmpliûÿÿÿt base_packagettemplate_renderers%s.pyN( tsplittendswithtfind_dirR t load_contenttostpathtjoint ensure_file( Rttemplatetdesttfilenametadd_pytpackageRRtcdirtcontent((s:/usr/lib/python2.6/site-packages/paste/script/filemaker.pyt copy_file/s  cCs t‚dS(s4 Copy a directory recursively, processing any files within it that need to be processed (end in _tmpl). template_dir Directory under self.source_dir to copy/process dest Destination directory into which this directory will be copied to. destname Use this name instead of the original template_dir name for creating the directory package This directory will be a Python package and needs to have a __init__.py file. N(tNotImplementedError(Rt template_dirRtdestnameR ((s:/usr/lib/python2.6/site-packages/paste/script/filemaker.pytcopy_dirTsc Cstii||dƒ}t}tii|ƒpk|ioEdi|id|gƒ}ti|id|ƒ} t }|}qtii|i|ƒ}n|o)t |dƒ} | i ƒ} | i ƒn|i dƒo%ti| |id|d|ƒ} n| S( Ns.pyRiitrRRR(RRRtTruetexistsR R t pkg_resourcestresource_stringtFalsetopentreadtcloseRRtsubstitute_contentR ( RRtbasetnameRRtblankt read_contenttfullpathR"tf((s:/usr/lib/python2.6/site-packages/paste/script/filemaker.pyRhs(     c CsŽtitiƒƒ}ttii|dƒƒ}g}|iƒD];}|iƒo(|iƒi dƒ o||iƒqAqA~}|i ƒt |ƒpt d|ƒ‚ntii |ƒ}g} xP|D]H} tii|| |ƒ} tii| ƒo| i| | fƒqÏqÏW| p7|itii||d|ƒd|ƒ|i|ƒSt | ƒdjot d|| fƒ‚n| dS(Ns top_level.txtt#sNo top level dir found for %siR isMultiple %s dirs found (%s)(Rtfind_egg_info_dirRtgetcwdR.RRt readlineststript startswithR0tlenRtdirnameR*tappendt ensure_dirR( RR?R tegg_infoR7t_[1]tltpackagesR2tpossibletpkgtd((s:/usr/lib/python2.6/site-packages/paste/script/filemaker.pyR€s,>  "cCsï|idƒo|d }nd|jo|idtiiƒ}ndtiijo|idtiiƒ}n|itiiƒ}|d}|d p d}n<t|d ƒdjo|d}ntii|d Œ}||fS( s Given the name, assume that the first argument is a path/filename combination. Return the name and dir of this. If the name ends with '.py' that will be erased. Examples: comments -> comments, '' admin/comments -> comments, 'admin' h/ab/fred -> fred, 'h/ab' s.pyiýÿÿÿt.Riÿÿÿÿtii(RtreplaceRRtsepRR>R(RR3tpartstdir((s:/usr/lib/python2.6/site-packages/paste/script/filemaker.pytparse_path_name_argsšs     cCs©|itiƒ}|pdStii|ƒpN|itii|ƒd|d|ƒ|iod|i|ƒGHn|i pti |ƒn|oBtiitii tii|ƒdƒƒo|i d|ƒn|oštii |dƒ}t |dƒ}|id ƒ|iƒd|i|ƒGH|oBtiitii tii|ƒdƒƒo|i d|ƒq{q¥n'|id jod |i|ƒGHndS( sq 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. package If package is True, any directories created will contain a __init__.py file. Ntsvn_addR s Creating %ss.svntadds __init__.pytwbs# isDirectory already exists: %s(trstripRRLRR*RAR?RtshortenRtmkdirRt svn_commandR.twriteR0(RRNRPR tinitfileR7((s:/usr/lib/python2.6/site-packages/paste/script/filemaker.pyRA·s. %  .  .c CsN|itii|ƒd|d|ƒtii|ƒp™|io d|GHn|ip*t|dƒ}|i|ƒ|i ƒn|oBtiitii tii|ƒdƒƒo|i d|ƒndSt|dƒ}|i ƒ}|i ƒ||jo"|id jo d |GHndS|i oÐd |GHtdjod dkanti|iƒ|iƒd ||ƒ}di |ƒGH|i obxctdƒiƒiƒ}|p d}n|idƒoPn|idƒodSdGHq˜qÿdSn|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. RPR s Creating %sRRs.svnRQNtrbis File %s matches expected contents0Warning: file %s does not match expected contentiÿÿÿÿs expected s s'Overwrite file with new content? [y/N] tntysUnknown response; Y or N pleasesOverwriting %s with new content(RARRR?R*RRR.RWR0RRVR/RtdifflibRt context_difft splitlinest raw_inputR<tlowerR=( RRR"RPR R7t old_contenttdiffts((s:/usr/lib/python2.6/site-packages/paste/script/filemaker.pyRâs\%    5                 cGsb|otii||Œ}n|itiƒƒo$|ttiƒƒitiiƒS|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(RRRR=R:R>tlstripRL(Rtfntpaths((s:/usr/lib/python2.6/site-packages/paste/script/filemaker.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(t run_commandtOSErrort _svn_failedR)(Rtargstkwte((s:/usr/lib/python2.6/site-packages/paste/script/filemaker.pyRV*s   c OsÄt|dtiƒƒ}t|dtƒ}t|dtƒ}|o ti}n ti}y5ti|gt|ƒd|d|dtiƒ}WnBt j o6} | i djo‚nt d|| fƒ‚nX|i od|d i |ƒfGHn|i odS|iƒ\} } |io^| oV|i pd|d i |ƒfGHnd |iGH| o | GHnt d |ƒ‚n|i djo.| od GH| GHn| od GH| GHqÀn| S(sw Runs the command, respecting verbosity and simulation. Returns stdout, or None if simulating. tcwdtcapture_stderrtexpect_returncodetstderrtstdoutis-The expected executable %s was not found (%s)s Running %s %st sError (exit code: %s)sError executing command %ssCommand error output:sCommand output:N(t popdefaultRR:R-t subprocesstSTDOUTtPIPEtPopentlistRiterrnoRRRRt communicatet returncode( RtcmdRkRlRnRoRpt stderr_pipetprocRmRrRq((s:/usr/lib/python2.6/site-packages/paste/script/filemaker.pyRh5sJ         N(t__name__t __module__t__doc__R-R)RRR#R'RRRORARRTRjRVRh(((s:/usr/lib/python2.6/site-packages/paste/script/filemaker.pyRs$   $   +8  cCs+||jo|S||}||=|SdS(N((tdictR3tdefaulttv((s:/usr/lib/python2.6/site-packages/paste/script/filemaker.pyRtcs   (RtglobR+t paste.scriptRRtpaste.script.commandRRR\Rut ImportErrortpaste.script.utilRtobjectRRt(((s:/usr/lib/python2.6/site-packages/paste/script/filemaker.pyts   ÿV