more python 2.3 compat, should be the last of it.
authorCampbell Barton <ideasman42@gmail.com>
Tue, 21 Oct 2008 09:08:46 +0000 (09:08 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 21 Oct 2008 09:08:46 +0000 (09:08 +0000)
release/scripts/DirectX8Exporter.py
release/scripts/uvcalc_lightmap.py
release/scripts/wizard_curve2tree.py

index 01212545f775b63724d81c5dafedab79d89e4447..b8bdae4de2b5e66f2156e60cb35dbae6de7ebc95 100644 (file)
@@ -7,7 +7,7 @@
 # Tooltip: 'Export to DirectX text file format format for XNA Animation Component Library.'
 """
 __author__ = "vertex color exporting feature is added by mnemoto (original:minahito (original:Arben (Ben) Omari))"
-__url__ = ("blender", "elysiun", "Adjuster's site http://sunday-lab.blogspot.com/, Author's site http://www.omariben.too.it","Adjuster's site http://ex.homeunix.net/")
+__url__ = ("blender.org", "blenderartists.org", "Adjuster's site http://sunday-lab.blogspot.com/, Author's site http://www.omariben.too.it","Adjuster's site http://ex.homeunix.net/")
 __version__ = "3.1"
 
 __bpydoc__ = """\
index 37423b7197e2ac147a36ee76938b131ed4dfe481..1433ccbd13ab4ab0c13d55f475494c3196c9c333 100644 (file)
@@ -47,6 +47,12 @@ def AngleBetweenVecs(a1,a2):
        except:
                return 180.0
 
+# python 2.3 has no reversed() iterator. this will only work on lists and tuples
+try:
+       reversed
+except:
+       def reversed(l): return l[::-1]
+
 class prettyface(object):
        __slots__ = 'uv', 'width', 'height', 'children', 'xoff', 'yoff', 'has_parent', 'rot'
        def __init__(self, data):
@@ -451,7 +457,10 @@ PREF_MARGIN_DIV=           512):
                        # Even boxes in groups of 4
                        for d, boxes in even_dict.items():      
                                if d < max_int_dimension:
-                                       boxes.sort(key = lambda a: len(a.children))
+                                       # py 2.3 compat
+                                       try:    boxes.sort(key = lambda a: len(a.children))
+                                       except: boxes.sort(lambda a, b: cmp(len(a.children), len(b.children)))
+                                       
                                        while len(boxes) >= 4:
                                                # print "bar", len(boxes)
                                                ok = True
index 84b2cc76132d762794e0b16cb6c5aadb6c5a6d21..1965f9a50708c73119c8ac9733527f7549b25c3b 100644 (file)
@@ -61,6 +61,12 @@ def AngleBetweenVecsSafe(a1, a2):
        except:
                return 180.0
 
+# Python 2.3 has no reversed.
+try:
+       reversed
+except:
+       def reversed(l): return l[::-1]
+
 # Copied from blender, we could wrap this! - BKE_curve.c
 # But probably not toooo bad in python
 def forward_diff_bezier(q0, q1, q2, q3, pointlist, steps, axis):
@@ -268,7 +274,7 @@ class tree:
                # Sort from big to small, so big branches get priority
                # Py 2.3 dosnt have keywords in sort
                try:    self.branches_all.sort( key = lambda brch: -brch.bpoints[0].radius )
-               except: self.branches_all.sort( lambda brch_a, brch_b: cmp(brch_b.bpoints[0].radius, brch_a.bpoints[0].radius) )
+               except: self.branches_all.sort( lambda brch_a, brch_b: cmp(brch_b.bpoints[0].radius, brch_a.bpoints[0].radius) ) # py2.3
        
        
        def closestBranchPt(self, co):
@@ -1146,7 +1152,8 @@ class tree:
                                
                                # Try sorting by other properties! this is ok for now
                                for segments_level_current in segments_level:
-                                       segments_level_current.sort( key = lambda seg:  -(seg.headCo-seg.tailCo).length )
+                                       try:    segments_level_current.sort( key = lambda seg:  -(seg.headCo-seg.tailCo).length )
+                                       except: segments_level_current.sort( lambda a,b: cmp((b.headCo-b.tailCo).length, (a.headCo-a.tailCo).length) ) # py2.3
                                
                                for level in xrange(twig_fill_levels):
                                        if len(segments_level) > level:
@@ -1372,18 +1379,23 @@ class tree:
                
                # Get the branches based on our selection method!
                if twig_select_mode==0:
-                       branches_sorted.sort( key = lambda brch: brch.getLength())
+                       try:    branches_sorted.sort( key = lambda brch: brch.getLength())
+                       except: branches_sorted.sort( lambda a,b: cmp(a.getLength(),a.getLength()) ) # py2.3
                elif twig_select_mode==1:
-                       branches_sorted.sort( key = lambda brch:-brch.getLength())
+                       try:    branches_sorted.sort( key = lambda brch:-brch.getLength())
+                       except: branches_sorted.sort( lambda a,b: cmp(b.getLength(), a.getLength()) ) # py2.3
                elif twig_select_mode==2:
-                       branches_sorted.sort( key = lambda brch:brch.getStraightness())
+                       try:    branches_sorted.sort( key = lambda brch:brch.getStraightness())
+                       except: branches_sorted.sort( lambda a,b: cmp(a.getStraightness(), b.getStraightness())) # py2.3
                elif twig_select_mode==3:
-                       branches_sorted.sort( key = lambda brch:-brch.getStraightness())
+                       try:    branches_sorted.sort( key = lambda brch:-brch.getStraightness())
+                       except: branches_sorted.sort( lambda a,b: cmp(b.getStraightness(), a.getStraightness())) # py2.3
                
                factor_int = int(len(self.branches_all) * twig_select_factor)
                branches_sorted[factor_int:] = []  # remove the last part of the list
                
-               branches_sorted.sort( key = lambda brch: len(brch.bpoints))
+               try:    branches_sorted.sort( key = lambda brch: len(brch.bpoints))
+               except: branches_sorted.sort( lambda a,b: cmp(len(a.bpoints), len(b.bpoints)) ) # py2.3
                
                branches_new = []
                #for i in xrange(ratio_int):