ó
£áSc           @` sÖ   d  Z  d d l m Z m Z m Z g  Z d d l Z e j d ƒ d d l Z d d l	 Z	 d d l
 Z
 d „  Z d „  Z d „  Z d „  Z e	 j j d	 „ Z d
 „  Z e	 j j d „ Z e d k rÒ e e j ƒ n  d S(   s`   
This module converts code written for numpy.numarray to work
with numpy

FIXME:  finish this.

i    (   t   divisiont   absolute_importt   print_functionNs.   numpy.numarray.alter_code2 is not working yet.c         C` s*   t  |  d ƒ } | j | ƒ | j ƒ  d  S(   Nt   w(   t   filet   writet   close(   t   namet   filestrt   fid(    (    sT   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/numarray/alter_code2.pyt   makenewfile   s    c         C` sO   t  |  ƒ } | j ƒ  } | j ƒ  t j j |  ƒ \ } } t | d | ƒ | S(   Ns   .orig(   R   t   readR   t   ost   patht   splitextR
   (   R   R	   R   t   baset   ext(    (    sT   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/numarray/alter_code2.pyt
   getandcopy   s    
c         C` s)   t  |  ƒ } t | ƒ } t |  | ƒ d S(   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(   R   t   fromstrR
   (   t   filenameR   (    (    sT   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/numarray/alter_code2.pyt   convertfile    s    c         C` s   |  d } t  | ƒ d  S(   Ni   (   R   (   t   argsR   (    (    sT   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/numarray/alter_code2.pyt   fromargs*   s    
c         C` s=   t  j  t j j |  d ƒ ƒ } x | D] } t | ƒ q% Wd S(   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(   t   globR   R   t   joinR   (   t   direct   filest   afile(    (    sT   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/numarray/alter_code2.pyt
   convertall.   s    c         C` s   t  | ƒ d  S(   N(   R   (   t   argt   dirnamet   fnames(    (    sT   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/numarray/alter_code2.pyt   _func9   s    c         C` s   t  j j |  t d ƒ d S(   s-   Convert all .py files in the tree given

    N(   R   R   t   walkR    t   None(   R   (    (    sT   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/numarray/alter_code2.pyt   converttree<   s    t   __main__(   t   __doc__t
   __future__R    R   R   t   __all__t   warningst   warnt   sysR   R   R
   R   R   R   R   t   curdirR   R    R#   t   __name__t   argv(    (    (    sT   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/numarray/alter_code2.pyt   <module>   s    			
		