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:
commit
21aef52194
41 changed files with 280 additions and 326 deletions
|
|
@ -66,6 +66,9 @@ LIBCRYPT = @LIBCRYPT@
|
||||||
SYSLIBS = $(LIBM) $(LIBC) $(LIBCRYPT)
|
SYSLIBS = $(LIBM) $(LIBC) $(LIBCRYPT)
|
||||||
LIBPREFIX =
|
LIBPREFIX =
|
||||||
|
|
||||||
|
PEP8 = @PEP8@
|
||||||
|
PEP8_FLAGS = --ignore=E402,E501,E30,W291,W391
|
||||||
|
|
||||||
# RUNTOOL is for use with runtime tools, eg set it to valgrind
|
# RUNTOOL is for use with runtime tools, eg set it to valgrind
|
||||||
RUNTOOL =
|
RUNTOOL =
|
||||||
# COMPILETOOL is a way to run the compiler under another tool, or more commonly just to stop the compiler executing
|
# COMPILETOOL is a way to run the compiler under another tool, or more commonly just to stop the compiler executing
|
||||||
|
|
@ -372,7 +375,7 @@ endif
|
||||||
|
|
||||||
PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'`
|
PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'`
|
||||||
|
|
||||||
python_run: $(PYSCRIPT)
|
python_run: $(PYSCRIPT) python_check
|
||||||
export PYTHONPATH=".:$$PYTHONPATH"; \
|
export PYTHONPATH=".:$$PYTHONPATH"; \
|
||||||
$(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE)
|
$(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE)
|
||||||
|
|
||||||
|
|
@ -385,6 +388,16 @@ $(RUNME)3.py: $(SRCDIR)$(RUNME).py
|
||||||
cp $< $@
|
cp $< $@
|
||||||
$(PY2TO3) -w $@ >/dev/null 2>&1
|
$(PY2TO3) -w $@ >/dev/null 2>&1
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
# Run Python pep8 if it exists
|
||||||
|
# -----------------------------------------------------------------
|
||||||
|
|
||||||
|
python_check: $(PYSCRIPT)
|
||||||
|
+if [ -n "$(PEP8)" ]; then \
|
||||||
|
$(PEP8) $(PEP8_FLAGS) $(PYSCRIPT) || true;\
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# Version display
|
# Version display
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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')"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,3 @@ try:
|
||||||
q.dequeue()
|
q.dequeue()
|
||||||
except example.EmptyError, e:
|
except example.EmptyError, e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,3 @@ for i in range(0,100):
|
||||||
|
|
||||||
print a.result()
|
print a.result()
|
||||||
print b.result()
|
print b.result()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,3 @@ if y:
|
||||||
print "bad swig"
|
print "bad swig"
|
||||||
else:
|
else:
|
||||||
print "good swig"
|
print "good swig"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,3 @@ if y:
|
||||||
print "bad swig"
|
print "bad swig"
|
||||||
else:
|
else:
|
||||||
print "good swig"
|
print "good swig"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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()
|
||||||
|
|
|
||||||
|
|
@ -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):
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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):
|
||||||
|
|
|
||||||
|
|
@ -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):
|
||||||
|
|
|
||||||
|
|
@ -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):
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,4 +60,3 @@ print "Cleaning up"
|
||||||
del va
|
del va
|
||||||
del a
|
del a
|
||||||
del b
|
del b
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,5 +30,3 @@ print sum
|
||||||
|
|
||||||
del iv
|
del iv
|
||||||
del dv
|
del dv
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue