Current File : //proc/self/root/proc/self/root/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code2.pyo
�
E�`Qc@s�dZgZddlZejd�ddlZddlZddlZddlZd�Zd�Z	d�Z
d�ZddlZd�Z
d	�Zd
�Zd�Zd�Zejjd
�Zd�Zejjd�Zedkr�eej�ndS(s�
This module converts code written for numpy.oldnumeric to work
with numpy

FIXME:  Flesh this out.

Makes the following changes:
 * Converts typecharacters '1swu' to 'bhHI' respectively
   when used as typecodes
 * Changes import statements
 * Change typecode= to dtype=
 * Eliminates savespace=xxx keyword arguments
 *  Removes it when keyword is not given as well
 * replaces matrixmultiply with dot
 * converts functions that don't give axis= keyword that have changed
 * converts functions that don't give typecode= keyword that have changed
 * converts use of capitalized type-names
 * converts old function names in oldnumeric.linear_algebra,
   oldnumeric.random_array, and oldnumeric.fft

i����Ns0numpy.oldnumeric.alter_code2 is not working yet.cCs^|jdd�}|jdd�}|jdd�}|jdd�}|jdd	�}|S(
Ns's's'h's'b's'B's'1's'w's'H's'u's'I'(treplace(tastr((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code2.pytreplacetypechars#scCs�d|}d|}d|}d}|j|d|�}|j|d||f�}d}t|�}td|�}	xn|j||�}
|
dkr�Pn|
|}||dkr�q{nd||
 |||f}||	|7}q{||fS(Ns	import %ss
import %s as sfrom %s import isimport %s as %st*s%sfrom %s import %s(Rtlentfind(tfstrtnametnewnamet	importstrtimportasstrtfromstrtfromalltindtNlentNlen2tfound((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code2.pyt
changeimports+s&



cCs|jdd�}|S(Ntmatrixmultiplytdot(R(R((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code2.pytreplaceattrBscCs=tjdd|�}|jdd�}|jdd�}|S(Nstypecode\s*=sdtype=t	ArrayTypetndarraytNewAxistnewaxis(tretsubR(R((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code2.pytreplaceotherFscCsNt|dd�\}}t|dd�\}}t|dd�\}}t|dd�\}}t|dd�\}}t|d	d
�\}}t|dd�\}}t|d
d�\}}t|dd�\}}|p�tp�|}t|�}t|�}tjj�jd�}tj	j
tjd�d}d|||f}|S(Nsnumpy.oldnumerictnumpysnumpy.core.multiarraysnumpy.core.umatht
LinearAlgebrasnumpy.linalg.oldtRNGsnumpy.random.oldrngsRNG.Statisticssnumpy.random.oldrngstatstRandomArraysnumpy.random.oldrandomarraytFFTs
numpy.fft.oldtMAs
numpy.core.mas	%b %d, %Yii����s/## Automatically adapted for numpy %s by %s

%s(
Rtfromall2RRtdatetimetdatettodaytstrftimetostpathtsplittsystargv(tfilestrtfromall1tfromall3RR%R((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code2.pyRMs$	cCs*t|d�}|j|�|j�dS(Ntw(tfiletwritetclose(RR,tfid((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code2.pytmakenewfilebs
cCsOt|�}|j�}|j�tjj|�\}}t|d|�|S(Ns.orig(R0treadR2R'R(tsplitextR4(RR3R,tbasetext((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code2.pyt
getandcopygs
cCs)t|�}t|�}t||�dS(s�Convert 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
    N(R9RR4(tfilenameR,((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code2.pytconvertfileoscCs|d}t|�dS(Ni(R;(targsR:((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code2.pytfromargsys
cCs=tjtjj|d��}x|D]}t|�q%WdS(s�Convert all .py files to use NumPy (from Numeric) in the directory given

    For each file, a backup of <usesnumeric>.py is made as
    <usesnumeric>.py.orig.  A new file named <usesnumeric>.py
    is then written with the updated code.
    s*.pyN(tglobR'R(tjoinR;(tdirectfilestafile((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code2.pyt
convertall}s
cCst|�dS(N(RC(targtdirnametfnames((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code2.pyt_func�scCstjj|td�dS(s-Convert all .py files in the tree given

    N(R'R(twalkRGtNone(R@((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code2.pytconverttree�st__main__(t__doc__t__all__twarningstwarnR*R'RR>RRRRR#RR4R9R;R=R(tcurdirRCRGRJt__name__R+(((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code2.pyt<module>s,