autopep8 cleanup of Examples/python whitespace

automated cleanup only of the Examples/python example code
This commit is contained in:
Jon Schlueter 2015-05-08 08:33:29 -04:00
commit 7770715457
40 changed files with 264 additions and 323 deletions

View file

@ -6,8 +6,10 @@ import example
class PyCallback(example.Callback): class PyCallback(example.Callback):
def __init__(self): def __init__(self):
example.Callback.__init__(self) example.Callback.__init__(self)
def run(self): def run(self):
print "PyCallback.run()" print "PyCallback.run()"
@ -25,7 +27,7 @@ callback = example.Callback()
callback.thisown = 0 callback.thisown = 0
caller.setCallback(callback) caller.setCallback(callback)
caller.call() caller.call()
caller.delCallback(); caller.delCallback()
print print
print "Adding and calling a Python callback" print "Adding and calling a Python callback"
@ -53,4 +55,3 @@ caller.delCallback()
print print
print "python exit" print "python exit"

View file

@ -21,7 +21,3 @@ try:
print "FOO = ", example.FOO, "(Arg! This shouldn't print anything)" print "FOO = ", example.FOO, "(Arg! This shouldn't print anything)"
except AttributeError: except AttributeError:
print "FOO isn't defined (good)" print "FOO isn't defined (good)"

View file

@ -19,12 +19,3 @@ example.cvar.Foo = 3.1415926
# See if the change took effect # See if the change took effect
print "Foo = ", example.cvar.Foo print "Foo = ", example.cvar.Foo

View file

@ -3,4 +3,3 @@
import example import example
print "example.Foo.bar.__doc__ =", repr(example.Foo.bar.__doc__), "(Should be 'No comment')" print "example.Foo.bar.__doc__ =", repr(example.Foo.bar.__doc__), "(Should be 'No comment')"

View file

@ -28,4 +28,3 @@ f = example.Foo()
f.enum_test(example.Foo.IMPULSE) f.enum_test(example.Foo.IMPULSE)
f.enum_test(example.Foo.WARP) f.enum_test(example.Foo.WARP)
f.enum_test(example.Foo.LUDICROUS) f.enum_test(example.Foo.LUDICROUS)

View file

@ -29,7 +29,8 @@ else:
try: try:
t.hosed() t.hosed()
except BaseException, e: except BaseException, e:
# Throwing builtin classes as exceptions not supported (-builtin option) # Throwing builtin classes as exceptions not supported (-builtin
# option)
print e print e
for i in range(1, 4): for i in range(1, 4):
@ -39,5 +40,3 @@ for i in range(1,4):
print e.args[0] print e.args[0]
except example.Exc, e: except example.Exc, e:
print e.code, e.msg print e.code, e.msg

View file

@ -43,9 +43,3 @@ try:
q.dequeue() q.dequeue()
except example.EmptyError, e: except example.EmptyError, e:
pass pass

View file

@ -8,8 +8,10 @@ import example
# CEO class, which overrides Employee::getPosition(). # CEO class, which overrides Employee::getPosition().
class CEO(example.Manager): class CEO(example.Manager):
def __init__(self, name): def __init__(self, name):
example.Manager.__init__(self, name) example.Manager.__init__(self, name)
def getPosition(self): def getPosition(self):
return "CEO" return "CEO"
@ -78,4 +80,3 @@ print "----------------------"
# All done. # All done.
print "python exit" print "python exit"

View file

@ -14,4 +14,3 @@ for i in range(0,100):
print a.result() print a.result()
print b.result() print b.result()

View file

@ -105,7 +105,3 @@ if y:
print "bad swig" print "bad swig"
else: else:
print "good swig" print "good swig"

View file

@ -6,7 +6,7 @@ print "Testing " + testname + " - %module(package=...) + python 'import' in __in
import pkg1.pkg2.foo import pkg1.pkg2.foo
print " Finished importing pkg1.pkg2.foo" print " Finished importing pkg1.pkg2.foo"
var2 = pkg1.pkg2.foo.Pkg2_Foo(); var2 = pkg1.pkg2.foo.Pkg2_Foo()
if str(type(var2)).find("'pkg1.pkg2.foo.Pkg2_Foo'") == -1: if str(type(var2)).find("'pkg1.pkg2.foo.Pkg2_Foo'") == -1:
raise RuntimeError("failed type checking: " + str(type(var2))) raise RuntimeError("failed type checking: " + str(type(var2)))
print " Successfully created object pkg1.pkg2.foo.Pkg2_Foo" print " Successfully created object pkg1.pkg2.foo.Pkg2_Foo"

View file

@ -105,7 +105,3 @@ if y:
print "bad swig" print "bad swig"
else: else:
print "good swig" print "good swig"

View file

@ -18,10 +18,3 @@ print example.count("Hello World", "l")
# Call the capitalize function # Call the capitalize function
print example.capitalize("hello world") print example.capitalize("hello world")

View file

@ -18,4 +18,3 @@ print "e =",e
# Big expression # Big expression
f = ((a + b) * (c + b * e)) + (-a) f = ((a + b) * (c + b * e)) + (-a)
print "f =", f print "f =", f

View file

@ -2,6 +2,7 @@ import sys
sys.path.append('..') sys.path.append('..')
import harness import harness
def proc(mod): def proc(mod):
for i in range(1000000): for i in range(1000000):
x = mod.MyClass() x = mod.MyClass()

View file

@ -2,6 +2,7 @@ import sys
sys.path.append('..') sys.path.append('..')
import harness import harness
def proc(mod): def proc(mod):
x = mod.MyClass() x = mod.MyClass()
for i in range(10000000): for i in range(10000000):

View file

@ -3,6 +3,7 @@ import time
import imp import imp
from subprocess import * from subprocess import *
def run(proc): def run(proc):
try: try:
@ -15,14 +16,17 @@ def run (proc) :
print "%s took %f seconds" % (mod.__name__, t2 - t1) print "%s took %f seconds" % (mod.__name__, t2 - t1)
except IndexError: except IndexError:
proc = Popen([sys.executable, 'runme.py', 'Simple_baseline'], stdout=PIPE) proc = Popen(
[sys.executable, 'runme.py', 'Simple_baseline'], stdout=PIPE)
(stdout, stderr) = proc.communicate() (stdout, stderr) = proc.communicate()
print stdout print stdout
proc = Popen([sys.executable, 'runme.py', 'Simple_optimized'], stdout=PIPE) proc = Popen(
[sys.executable, 'runme.py', 'Simple_optimized'], stdout=PIPE)
(stdout, stderr) = proc.communicate() (stdout, stderr) = proc.communicate()
print stdout print stdout
proc = Popen([sys.executable, 'runme.py', 'Simple_builtin'], stdout=PIPE) proc = Popen(
[sys.executable, 'runme.py', 'Simple_builtin'], stdout=PIPE)
(stdout, stderr) = proc.communicate() (stdout, stderr) = proc.communicate()
print stdout print stdout

View file

@ -2,6 +2,7 @@ import sys
sys.path.append('..') sys.path.append('..')
import harness import harness
def proc(mod): def proc(mod):
x = mod.H() x = mod.H()
for i in range(10000000): for i in range(10000000):

View file

@ -2,6 +2,7 @@ import sys
sys.path.append('..') sys.path.append('..')
import harness import harness
def proc(mod): def proc(mod):
x = mod.H() x = mod.H()
for i in range(10000000): for i in range(10000000):

View file

@ -2,6 +2,7 @@ import sys
sys.path.append('..') sys.path.append('..')
import harness import harness
def proc(mod): def proc(mod):
x = mod.MyClass() x = mod.MyClass()
for i in range(10000000): for i in range(10000000):

View file

@ -1,14 +1,14 @@
# file: runme.py # file: runme.py
import example; import example
# First create some objects using the pointer library. # First create some objects using the pointer library.
print "Testing the pointer library"; print "Testing the pointer library"
a = example.new_intp(); a = example.new_intp()
b = example.new_intp(); b = example.new_intp()
c = example.new_intp(); c = example.new_intp()
example.intp_assign(a,37); example.intp_assign(a, 37)
example.intp_assign(b,42); example.intp_assign(b, 42)
print " a =", a print " a =", a
print " b =", b print " b =", b
@ -30,15 +30,12 @@ example.delete_intp(c)
# This should be much easier. Now how it is no longer # This should be much easier. Now how it is no longer
# necessary to manufacture pointers. # necessary to manufacture pointers.
print "Trying the typemap library"; print "Trying the typemap library"
r = example.sub(37, 42) r = example.sub(37, 42)
print " 37 - 42 =", r print " 37 - 42 =", r
# Now try the version with multiple return values # Now try the version with multiple return values
print "Testing multiple return values"; print "Testing multiple return values"
q, r = example.divide(42, 37) q, r = example.divide(42, 37)
print " 42/37 = %d remainder %d" % (q, r) print " 42/37 = %d remainder %d" % (q, r)

View file

@ -60,4 +60,3 @@ print "Cleaning up"
del va del va
del a del a
del b del b

View file

@ -19,12 +19,3 @@ example.cvar.Foo = 3.1415926
# See if the change took effect # See if the change took effect
print "Foo = ", example.cvar.Foo print "Foo = ", example.cvar.Foo

View file

@ -52,4 +52,3 @@ del ss
s = 3 s = 3
print example.cvar.Shape_nshapes, "shapes remain" print example.cvar.Shape_nshapes, "shapes remain"
print "Goodbye" print "Goodbye"

View file

@ -7,8 +7,6 @@ pmap["hi"] = 1
pmap["hello"] = 2 pmap["hello"] = 2
dmap = {} dmap = {}
dmap["hello"] = 1.0 dmap["hello"] = 1.0
dmap["hi"] = 2.0 dmap["hi"] = 2.0
@ -54,7 +52,6 @@ print hmap.keys()
print hmap.values() print hmap.values()
dmap = {} dmap = {}
dmap["hello"] = 2 dmap["hello"] = 2
dmap["hi"] = 4 dmap["hi"] = 4

View file

@ -33,4 +33,3 @@ example.halve_in_place(v)
for i in range(len(v)): for i in range(len(v)):
print v[i], "; ", print v[i], "; ",
print print

View file

@ -30,5 +30,3 @@ print sum
del iv del iv
del dv del dv

View file

@ -25,11 +25,3 @@ example.fprintf(stdout,"The value is %d\n")
# This function calls our NULL-terminated function # This function calls our NULL-terminated function
example.printv("Hello", "World", "this", "is", "a", "test.") example.printv("Hello", "World", "this", "is", "a", "test.")

View file

@ -46,16 +46,16 @@ print "\nVariables (values printed from C)"
example.print_vars() example.print_vars()
print "\nNow I'm going to try and modify some read only variables"; print "\nNow I'm going to try and modify some read only variables"
print " Tring to set 'path'"; print " Tring to set 'path'"
try: try:
example.cvar.path = "Whoa!" example.cvar.path = "Whoa!"
print "Hey, what's going on?!?! This shouldn't work" print "Hey, what's going on?!?! This shouldn't work"
except: except:
print "Good." print "Good."
print " Trying to set 'status'"; print " Trying to set 'status'"
try: try:
example.cvar.status = 0 example.cvar.status = 0
print "Hey, what's going on?!?! This shouldn't work" print "Hey, what's going on?!?! This shouldn't work"
@ -70,6 +70,3 @@ example.cvar.pt = example.cvar.ptptr
print "The new value is" print "The new value is"
example.pt_print() example.pt_print()
print "You should see the value", example.Point_print(example.cvar.ptptr) print "You should see the value", example.Point_print(example.cvar.ptptr)