summaryrefslogtreecommitdiff
path: root/numpy/lib/convertcode.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/convertcode.py')
-rw-r--r--numpy/lib/convertcode.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/numpy/lib/convertcode.py b/numpy/lib/convertcode.py
index 3e0a679f0..0c5a0833b 100644
--- a/numpy/lib/convertcode.py
+++ b/numpy/lib/convertcode.py
@@ -126,19 +126,30 @@ def getandcopy(name):
makenewfile(base+'.orig', filestr)
return filestr
-def fromfile(filename):
+def convertfile(filename):
+ """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
+ """
filestr = getandcopy(filename)
filestr = fromstr(filestr)
makenewfile(filename, filestr)
def fromargs(args):
filename = args[1]
- fromfile(filename)
+ convertfile(filename)
+
+def convertall(direc=os.path.curdir):
+ """Convert all .py files to use NumPy (from Numeric) in the directory given
-def convertall(direc=''):
+ 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.
+ """
files = glob.glob(os.path.join(direc,'*.py'))
for afile in files:
- fromfile(afile)
+ convertfile(afile)
if __name__ == '__main__':
fromargs(sys.argv)