Kc@sdZdddgZddlZddlZddlZddlZdddgZd d d d d dddgZddddddddddddddgZeeZ iZ x+e D]#Z de Z ej e e e sh              cCsd}d}|j|}|dkrd}x:|D]2}|jd||}|dkr4d}Pq4q4W|rd|| d||t|f}|d7}qntjd}|j|} t| dkrx| D]} d}x=|D]5}|jd| |f}|dkrd}PqqW|rd | }|j|}d|| d | ||t|f}|d7}qqWnd }|j|}|dkr3d}xJ|D]B}|j||}|dkr||dtkrd}PqqW|r3d|| d ||t|f}|d7}q3nd}d }t|} x|j||}|dkrpPn|| 7}|d} d} xN| r|| dkr| d7} n|| dkr| d8} n| d7} qW||| !}d}|jdd}|jdd}g|jdD]}|j^q"}g}x7|D]/}||krG|j ||j |qGqGWt|dkrNd|| ddj |ddj ||| f}|d7}qNqN||fS(Nis import numpysnumpy.%sis%s%s%ss import numpy.oldnumeric as numpysimport numpy as ([A-Za-z0-9_]+)s%s.%ssimport numpy as %ssimport numpy.oldnumeric as %ssfrom numpy import *sfrom numpy.oldnumeric import *sfrom numpy imports\s R!RR&s %s%s %s %ssfrom numpy import %ss, sfrom numpy.oldnumeric import %s( tfindR,tretcompiletfindallR+treplacetsplittstriptremovetappendtjoin(R-tnamestnumt importstrtindtfoundR.tind2timportretmodulestmoduleRtptrR9tsubstrtxt importnamestaddnames((sE/usr/lib/python2.7/site-packages/numpy/oldnumeric/fix_default_axis.pyt_import_changevs                      (     cCsd}|s|x0tD](}t||d\}}||7}qWx0tD](}t||d\}}||7}qFW||fSt|tt\}}||fSdS(Nisaxis=-1saxis=0(t_funcm1R;t_func0RT(R-t import_changettotalR.RG((sE/usr/lib/python2.7/site-packages/numpy/oldnumeric/fix_default_axis.pytadd_axiss   cCs*t|d}|j||jdS(Ntw(tfiletwritetclose(R.tfilestrtfid((sE/usr/lib/python2.7/site-packages/numpy/oldnumeric/fix_default_axis.pyt makenewfiles cCs&t|}|j}|j|S(N(R[treadR](R.R_R^((sE/usr/lib/python2.7/site-packages/numpy/oldnumeric/fix_default_axis.pytgetfiles   cCs-tjj|\}}t|d|dS(Ns.orig(tostpathtsplitextR`(R.R-tbasetext((sE/usr/lib/python2.7/site-packages/numpy/oldnumeric/fix_default_axis.pytcopyfilescCsdt|}t||\}}|dkr`dG|GHt||t||tjjndS(sConvert the filename given from using Numeric to using NumPy Copies the file to filename.orig and then over-writes the file with the updated code is Changing N(RbRYRhR`tsyststdouttflush(tfilenameRWR^tnewstrRX((sE/usr/lib/python2.7/site-packages/numpy/oldnumeric/fix_default_axis.pyRs     cCs|d}t|dS(Ni(R(targsRl((sE/usr/lib/python2.7/site-packages/numpy/oldnumeric/fix_default_axis.pytfromargs s cCs@tjtjj|d}x|D]}t||q%WdS(sConvert all .py files in the directory given For each file, a backup of .py is made as .py.orig. A new file named .py is then written with the updated code. s*.pyN(tglobRcRdRER(tdirecRWtfilestafile((sE/usr/lib/python2.7/site-packages/numpy/oldnumeric/fix_default_axis.pyRs cCst|d|dS(NRW(R(targtdirnametfnames((sE/usr/lib/python2.7/site-packages/numpy/oldnumeric/fix_default_axis.pyt_funcscCstjj|t|dS(s-Convert all .py files in the tree given N(RcRdtwalkRw(RqRW((sE/usr/lib/python2.7/site-packages/numpy/oldnumeric/fix_default_axis.pyRst__main__(#t__doc__t__all__RiRcR=RpR'RURVt_allR(R.t_astrR>tstringt uppercaset lowercasetdigitsR+R;RTtFalseRYR`RbRhRRoRdtcurdirRRwRt__name__targv(((sE/usr/lib/python2.7/site-packages/numpy/oldnumeric/fix_default_axis.pyt#s>          8 g