summaryrefslogtreecommitdiff
path: root/numpy/oldnumeric/alter_code1.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-08-18 11:51:25 -0600
committerCharles Harris <charlesr.harris@gmail.com>2013-08-18 11:51:25 -0600
commitfbd6510d58a47ea0d166c48a82793f05425406e4 (patch)
tree330ce703eb02d20f96099c3fe0fc36ae33d4905b /numpy/oldnumeric/alter_code1.py
parent8ddb0ce0acafe75d78df528b4d2540dfbf4b364d (diff)
downloadnumpy-fbd6510d58a47ea0d166c48a82793f05425406e4.tar.gz
STY: Giant comma spacing fixup.
Run the 2to3 ws_comma fixer on *.py files. Some lines are now too long and will need to be broken at some point. OTOH, some lines were already too long and need to be broken at some point. Now seems as good a time as any to do this with open PRs at a minimum.
Diffstat (limited to 'numpy/oldnumeric/alter_code1.py')
-rw-r--r--numpy/oldnumeric/alter_code1.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/numpy/oldnumeric/alter_code1.py b/numpy/oldnumeric/alter_code1.py
index 34a59a7ca..2d4e17106 100644
--- a/numpy/oldnumeric/alter_code1.py
+++ b/numpy/oldnumeric/alter_code1.py
@@ -67,7 +67,7 @@ for char in _chars.keys():
def fixtypechars(fstr):
for name in _func2 + _func4 + _meth1:
- fstr = func_re[name].sub('\\1B\\2',fstr)
+ fstr = func_re[name].sub('\\1B\\2', fstr)
for char in _chars.keys():
fstr = meth_re[char].sub('\\1%s\\2'%_chars[char], fstr)
return fstr
@@ -83,13 +83,13 @@ def changeimports(fstr, name, newname):
fstr = re.sub(r'(import\s+[^,\n\r]+,\s*)(%s)' % name,
"\\1%s as %s" % (newname, name), fstr)
fstr = fstr.replace(importasstr, 'import %s as ' % newname)
- fstr = fstr.replace(importstr, 'import %s as %s' % (newname,name))
+ fstr = fstr.replace(importstr, 'import %s as %s' % (newname, name))
ind = 0
Nlen = len(fromstr)
Nlen2 = len("from %s import " % newname)
while True:
- found = fstr.find(fromstr,ind)
+ found = fstr.find(fromstr, ind)
if (found < 0):
break
ind = found + Nlen
@@ -111,15 +111,15 @@ def fixistesting(astr):
return astr
def replaceattr(astr):
- astr = astr.replace(".typecode()",".dtype.char")
- astr = astr.replace(".iscontiguous()",".flags.contiguous")
- astr = astr.replace(".byteswapped()",".byteswap()")
+ astr = astr.replace(".typecode()", ".dtype.char")
+ astr = astr.replace(".iscontiguous()", ".flags.contiguous")
+ astr = astr.replace(".byteswapped()", ".byteswap()")
astr = astr.replace(".toscalar()", ".item()")
- astr = astr.replace(".itemsize()",".itemsize")
+ astr = astr.replace(".itemsize()", ".itemsize")
# preserve uses of flat that should be o.k.
- tmpstr = flatindex_re.sub(r"@@@@\2",astr)
+ tmpstr = flatindex_re.sub(r"@@@@\2", astr)
# replace other uses of flat
- tmpstr = tmpstr.replace(".flat",".ravel()")
+ tmpstr = tmpstr.replace(".flat", ".ravel()")
# put back .flat where it was valid
astr = tmpstr.replace("@@@@", ".flat")
return astr
@@ -128,7 +128,7 @@ svspc2 = re.compile(r'([^,(\s]+[.]spacesaver[(][)])')
svspc3 = re.compile(r'(\S+[.]savespace[(].*[)])')
#shpe = re.compile(r'(\S+\s*)[.]shape\s*=[^=]\s*(.+)')
def replaceother(astr):
- astr = svspc2.sub('True',astr)
+ astr = svspc2.sub('True', astr)
astr = svspc3.sub(r'pass ## \1', astr)
#astr = shpe.sub('\\1=\\1.reshape(\\2)', astr)
return astr
@@ -139,7 +139,7 @@ def fromstr(filestr):
filestr = fixtypechars(filestr)
filestr = fixistesting(filestr)
filestr, fromall1 = changeimports(filestr, 'Numeric', 'numpy.oldnumeric')
- filestr, fromall1 = changeimports(filestr, 'multiarray','numpy.oldnumeric')
+ filestr, fromall1 = changeimports(filestr, 'multiarray', 'numpy.oldnumeric')
filestr, fromall1 = changeimports(filestr, 'umath', 'numpy.oldnumeric')
filestr, fromall1 = changeimports(filestr, 'Precision', 'numpy.oldnumeric.precision')
filestr, fromall1 = changeimports(filestr, 'UserArray', 'numpy.oldnumeric.user_array')
@@ -199,7 +199,7 @@ def convertall(direc=os.path.curdir, orig=1):
<usesnumeric>.py.orig. A new file named <usesnumeric>.py
is then written with the updated code.
"""
- files = glob.glob(os.path.join(direc,'*.py'))
+ files = glob.glob(os.path.join(direc, '*.py'))
for afile in files:
if afile[-8:] == 'setup.py': continue # skip these
convertfile(afile, orig)
@@ -211,16 +211,16 @@ def convertsrc(direc=os.path.curdir, ext=None, orig=1):
directory with extension give by list ext (if ext is None, then all files are
replaced)."""
if ext is None:
- files = glob.glob(os.path.join(direc,'*'))
+ files = glob.glob(os.path.join(direc, '*'))
else:
files = []
for aext in ext:
- files.extend(glob.glob(os.path.join(direc,"*.%s" % aext)))
+ files.extend(glob.glob(os.path.join(direc, "*.%s" % aext)))
for afile in files:
fid = open(afile)
fstr = fid.read()
fid.close()
- fstr, n = header_re.subn(r'numpy/oldnumeric.h',fstr)
+ fstr, n = header_re.subn(r'numpy/oldnumeric.h', fstr)
if n > 0:
if orig:
base, ext = os.path.splitext(afile)
@@ -231,7 +231,7 @@ def convertsrc(direc=os.path.curdir, ext=None, orig=1):
def _func(arg, dirname, fnames):
convertall(dirname, orig=0)
- convertsrc(dirname, ext=['h','c'], orig=0)
+ convertsrc(dirname, ext=['h', 'c'], orig=0)
def converttree(direc=os.path.curdir):
"""Convert all .py files and source code files in the tree given