Merge branch 'yazug-python_examples_pep8_whitespace_cleanup'

* yazug-python_examples_pep8_whitespace_cleanup:
  Fixup 2 additional whitespace warnings pep8 found
  Add pep8 check for Examples/python
  autopep8 cleanup of Examples/python whitespace
This commit is contained in:
William S Fulton 2015-05-10 18:43:37 +01:00
commit 21aef52194
40 changed files with 280 additions and 326 deletions

View file

@ -2,14 +2,16 @@
# This file illustrates the cross language polymorphism using directors.
import example
import example
class PyCallback(example.Callback):
def __init__(self):
example.Callback.__init__(self)
def run(self):
print "PyCallback.run()"
def __init__(self):
example.Callback.__init__(self)
def run(self):
print "PyCallback.run()"
# Create an Caller instance
@ -25,7 +27,7 @@ callback = example.Callback()
callback.thisown = 0
caller.setCallback(callback)
caller.call()
caller.delCallback();
caller.delCallback()
print
print "Adding and calling a Python callback"
@ -53,4 +55,3 @@ caller.delCallback()
print
print "python exit"

View file

@ -3,7 +3,7 @@
# This file illustrates the proxy class C++ interface generated
# by SWIG.
import example
import example
# ----- Object creation -----
@ -15,7 +15,7 @@ print " Created square", s
# ----- Access a static member -----
print "\nA total of", example.cvar.Shape_nshapes,"shapes were created"
print "\nA total of", example.cvar.Shape_nshapes, "shapes were created"
# ----- Member data access -----
@ -28,16 +28,16 @@ s.x = -10
s.y = 5
print "\nHere is their current position:"
print " Circle = (%f, %f)" % (c.x,c.y)
print " Square = (%f, %f)" % (s.x,s.y)
print " Circle = (%f, %f)" % (c.x, c.y)
print " Square = (%f, %f)" % (s.x, s.y)
# ----- Call some methods -----
print "\nHere are some properties of the shapes:"
for o in [c,s]:
print " ", o
print " area = ", o.area()
print " perimeter = ", o.perimeter()
for o in [c, s]:
print " ", o
print " area = ", o.area()
print " perimeter = ", o.perimeter()
# prevent o from holding a reference to the last object looked at
o = None
@ -47,5 +47,5 @@ print "\nGuess I'll clean up now"
del c
del s
print example.cvar.Shape_nshapes,"shapes remain"
print example.cvar.Shape_nshapes, "shapes remain"
print "Goodbye"

View file

@ -1,6 +1,6 @@
# file: runme.py
import example
import example
print "ICONST =", example.ICONST, "(should be 42)"
print "FCONST =", example.FCONST, "(should be 2.1828)"
@ -8,7 +8,7 @@ print "CCONST =", example.CCONST, "(should be 'x')"
print "CCONST2 =", example.CCONST2, "(this should be on a new line)"
print "SCONST =", example.SCONST, "(should be 'Hello World')"
print "SCONST2 =", example.SCONST2, "(should be '\"Hello World\"')"
print "EXPR =", example.EXPR, "(should be 48.5484)"
print "EXPR =", example.EXPR, "(should be 48.5484)"
print "iconst =", example.iconst, "(should be 37)"
print "fconst =", example.fconst, "(should be 3.14)"
@ -21,7 +21,3 @@ try:
print "FOO = ", example.FOO, "(Arg! This shouldn't print anything)"
except AttributeError:
print "FOO isn't defined (good)"

View file

@ -1,13 +1,13 @@
# file: runme.py
import example
import example
# Call our gcd() function
x = 42
y = 105
g = example.gcd(x,y)
print "The gcd of %d and %d is %d" % (x,y,g)
g = example.gcd(x, y)
print "The gcd of %d and %d is %d" % (x, y, g)
# Manipulate the Foo global variable
@ -19,12 +19,3 @@ example.cvar.Foo = 3.1415926
# See if the change took effect
print "Foo = ", example.cvar.Foo

View file

@ -1,6 +1,5 @@
# file: runme.py
import example
import example
print "example.Foo.bar.__doc__ =", repr(example.Foo.bar.__doc__), "(Should be 'No comment')"

View file

@ -18,9 +18,9 @@ print " Foo_LUDICROUS =", example.Foo.LUDICROUS
print "\nTesting use of enums with functions\n"
example.enum_test(example.RED, example.Foo.IMPULSE)
example.enum_test(example.BLUE, example.Foo.WARP)
example.enum_test(example.BLUE, example.Foo.WARP)
example.enum_test(example.GREEN, example.Foo.LUDICROUS)
example.enum_test(1234,5678)
example.enum_test(1234, 5678)
print "\nTesting use of enum with class method"
f = example.Foo()
@ -28,4 +28,3 @@ f = example.Foo()
f.enum_test(example.Foo.IMPULSE)
f.enum_test(example.Foo.WARP)
f.enum_test(example.Foo.LUDICROUS)

View file

@ -6,38 +6,37 @@ import example
t = example.Test()
try:
t.unknown()
except RuntimeError,e:
print "incomplete type", e.args[0]
t.unknown()
except RuntimeError, e:
print "incomplete type", e.args[0]
try:
t.simple()
except RuntimeError,e:
print e.args[0]
t.simple()
except RuntimeError, e:
print e.args[0]
try:
t.message()
except RuntimeError,e:
print e.args[0]
t.message()
except RuntimeError, e:
print e.args[0]
if not example.is_python_builtin():
try:
try:
t.hosed()
except example.Exc,e:
except example.Exc, e:
print e.code, e.msg
else:
try:
try:
t.hosed()
except BaseException,e:
# Throwing builtin classes as exceptions not supported (-builtin option)
except BaseException, e:
# Throwing builtin classes as exceptions not supported (-builtin
# option)
print e
for i in range(1,4):
try:
t.multi(i)
except RuntimeError,e:
print e.args[0]
except example.Exc,e:
print e.code, e.msg
for i in range(1, 4):
try:
t.multi(i)
except RuntimeError, e:
print e.args[0]
except example.Exc, e:
print e.code, e.msg

View file

@ -2,8 +2,8 @@
import example
if example.is_python_builtin():
print "Skipping example: -builtin option does not support %exceptionclass"
exit(0)
print "Skipping example: -builtin option does not support %exceptionclass"
exit(0)
q = example.intQueue(10)
@ -12,18 +12,18 @@ print "Inserting items into intQueue"
print type(example.FullError)
try:
for i in range(0,100):
q.enqueue(i)
except example.FullError,e:
print "Maxsize is", e.maxsize
for i in range(0, 100):
q.enqueue(i)
except example.FullError, e:
print "Maxsize is", e.maxsize
print "Removing items"
try:
while 1:
q.dequeue()
except example.EmptyError,e:
pass
while 1:
q.dequeue()
except example.EmptyError, e:
pass
q = example.doubleQueue(1000)
@ -31,21 +31,15 @@ q = example.doubleQueue(1000)
print "Inserting items into doubleQueue"
try:
for i in range(0,10000):
q.enqueue(i*1.5)
except example.FullError,e:
print "Maxsize is", e.maxsize
for i in range(0, 10000):
q.enqueue(i * 1.5)
except example.FullError, e:
print "Maxsize is", e.maxsize
print "Removing items"
try:
while 1:
q.dequeue()
except example.EmptyError,e:
pass
while 1:
q.dequeue()
except example.EmptyError, e:
pass

View file

@ -2,16 +2,18 @@
# This file illustrates the cross language polymorphism using directors.
import example
import example
# CEO class, which overrides Employee::getPosition().
class CEO(example.Manager):
def __init__(self, name):
example.Manager.__init__(self, name)
def getPosition(self):
return "CEO"
def __init__(self, name):
example.Manager.__init__(self, name)
def getPosition(self):
return "CEO"
# Create an instance of our employee extension class, CEO. The calls to
@ -78,4 +80,3 @@ print "----------------------"
# All done.
print "python exit"

View file

@ -1,6 +1,6 @@
# file: runme.py
import example
import example
a = 37
b = 42
@ -10,9 +10,9 @@ b = 42
print "Trying some C callback functions"
print " a =", a
print " b =", b
print " ADD(a,b) =", example.do_op(a,b,example.ADD)
print " SUB(a,b) =", example.do_op(a,b,example.SUB)
print " MUL(a,b) =", example.do_op(a,b,example.MUL)
print " ADD(a,b) =", example.do_op(a, b, example.ADD)
print " SUB(a,b) =", example.do_op(a, b, example.SUB)
print " MUL(a,b) =", example.do_op(a, b, example.MUL)
print "Here is what the C callback function objects look like in Python"
print " ADD =", example.ADD

View file

@ -1,6 +1,6 @@
# file: runme.py
import example
import example
a = 37
b = 42
@ -10,9 +10,9 @@ b = 42
print "Trying some C callback functions"
print " a =", a
print " b =", b
print " ADD(a,b) =", example.do_op(a,b,example.ADD)
print " SUB(a,b) =", example.do_op(a,b,example.SUB)
print " MUL(a,b) =", example.do_op(a,b,example.MUL)
print " ADD(a,b) =", example.do_op(a, b, example.ADD)
print " SUB(a,b) =", example.do_op(a, b, example.SUB)
print " MUL(a,b) =", example.do_op(a, b, example.MUL)
print "Here is what the C callback function objects look like in Python"
print " ADD =", example.ADD
@ -20,5 +20,5 @@ print " SUB =", example.SUB
print " MUL =", example.MUL
print "Call the functions directly..."
print " add(a,b) =", example.add(a,b)
print " sub(a,b) =", example.sub(a,b)
print " add(a,b) =", example.add(a, b)
print " sub(a,b) =", example.sub(a, b)

View file

@ -8,10 +8,9 @@ b = example.doubleSum(100.0)
# Use the objects. They should be callable just like a normal
# python function.
for i in range(0,100):
for i in range(0, 100):
a(i) # Note: function call
b(math.sqrt(i)) # Note: function call
print a.result()
print b.result()

View file

@ -81,31 +81,27 @@ x = d.toBase()
print " Spam -> Base -> Foo : ",
y = foo.Foo_fromBase(x)
if y:
print "bad swig"
print "bad swig"
else:
print "good swig"
print "good swig"
print " Spam -> Base -> Bar : ",
y = bar.Bar_fromBase(x)
if y:
print "good swig"
print "good swig"
else:
print "bad swig"
print "bad swig"
print " Spam -> Base -> Spam : ",
y = spam.Spam_fromBase(x)
if y:
print "good swig"
print "good swig"
else:
print "bad swig"
print "bad swig"
print " Foo -> Spam : ",
y = spam.Spam_fromBase(b)
if y:
print "bad swig"
print "bad swig"
else:
print "good swig"
print "good swig"

View file

@ -5,9 +5,9 @@ import os.path
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
if sys.version_info < (3,0):
import py2.pkg2
print " Finished importing py2.pkg2"
if sys.version_info < (3, 0):
import py2.pkg2
print " Finished importing py2.pkg2"
else:
import py3.pkg2
print " Finished importing py3.pkg2"
import py3.pkg2
print " Finished importing py3.pkg2"

View file

@ -5,9 +5,9 @@ import os.path
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
if sys.version_info < (3,0):
import py2.pkg2
print " Finished importing py2.pkg2"
if sys.version_info < (3, 0):
import py2.pkg2
print " Finished importing py2.pkg2"
else:
import py3.pkg2
print " Finished importing py3.pkg2"
import py3.pkg2
print " Finished importing py3.pkg2"

View file

@ -5,9 +5,9 @@ import os.path
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
if sys.version_info < (3,0):
import py2.pkg2
print " Finished importing py2.pkg2"
if sys.version_info < (3, 0):
import py2.pkg2
print " Finished importing py2.pkg2"
else:
import py3.pkg2
print " Finished importing py3.pkg2"
import py3.pkg2
print " Finished importing py3.pkg2"

View file

@ -5,9 +5,9 @@ import os.path
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
print "Testing " + testname + " - %module(package=...) with -relativeimport"
if sys.version_info < (3,0):
import py2.pkg2.bar
print " Finished importing py2.pkg2.bar"
if sys.version_info < (3, 0):
import py2.pkg2.bar
print " Finished importing py2.pkg2.bar"
else:
import py3.pkg2.bar
print " Finished importing py3.pkg2.bar"
import py3.pkg2.bar
print " Finished importing py3.pkg2.bar"

View file

@ -5,9 +5,9 @@ import os.path
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
if sys.version_info < (3,0):
import py2.pkg2.bar
print " Finished importing py2.pkg2.bar"
if sys.version_info < (3, 0):
import py2.pkg2.bar
print " Finished importing py2.pkg2.bar"
else:
import py3.pkg2.bar
print " Finished importing py3.pkg2.bar"
import py3.pkg2.bar
print " Finished importing py3.pkg2.bar"

View file

@ -5,9 +5,9 @@ import os.path
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
print "Testing " + testname + " - %module(package=...) with -relativeimport"
if sys.version_info < (3,0):
import py2.pkg2.bar
print " Finished importing py2.pkg2.bar"
if sys.version_info < (3, 0):
import py2.pkg2.bar
print " Finished importing py2.pkg2.bar"
else:
import py3.pkg2.bar
print " Finished importing py3.pkg2.bar"
import py3.pkg2.bar
print " Finished importing py3.pkg2.bar"

View file

@ -9,5 +9,5 @@ print " Finished importing pkg2.foo"
var2 = pkg2.foo.Pkg2_Foo()
if str(type(var2)).find("'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 pkg2.foo.Pkg2_Foo"

Some files were not shown because too many files have changed in this diff Show more