yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #01797
[Branch ~yade-dev/yade/trunk] Rev 1716: Add python 2.5 compatibility hack
------------------------------------------------------------
revno: 1716
committer: Václav Šmilauer <vaclav@flux>
branch nick: trunk
timestamp: Fri 2009-08-21 13:59:41 +0200
message:
Add python 2.5 compatibility hack
modified:
py/pack.py
--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription.
=== modified file 'py/pack.py'
--- py/pack.py 2009-08-12 08:27:41 +0000
+++ py/pack.py 2009-08-21 11:59:41 +0000
@@ -5,6 +5,19 @@
from math import sqrt
from yade import utils
+from miniWm3Wrap import *
+from yade.wrapper import *
+
+## compatibility hack for python 2.5 (21/8/2009)
+## can be safely removed at some point
+if 'product' not in dir(itertools):
+ def product(*args, **kwds):
+ "http://docs.python.org/library/itertools.html#itertools.product"
+ pools = map(tuple, args) * kwds.get('repeat', 1); result = [[]]
+ for pool in pools: result = [x+[y] for x in result for y in pool]
+ for prod in result: yield tuple(prod)
+ itertools.product=product
+
# for now skip the import, but try in inGtsSurface constructor again, to give error if we really use it
try:
import gts
@@ -16,7 +29,6 @@
from _packSpheres import *
from _packObb import *
-from miniWm3Wrap import *
class inGtsSurface_py(Predicate):
"""This class was re-implemented in c++, but should stay here to serve as reference for implementing
@@ -247,7 +259,6 @@
sys.stdout.flush()
O.switchWorld() ### !!
if wantPeri:
- from yade.wrapper import *
#O.reset() # doesn't (shouldn't) affect the original simulation
sp=SpherePack()
cloudPorosity=0.25 # assume this number for the initial cloud (can be underestimated)