Revision: 17147
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17147
Author:   campbellbarton
Date:     2008-10-21 11:08:46 +0200 (Tue, 21 Oct 2008)

Log Message:
-----------
more python 2.3 compat, should be the last of it.

Modified Paths:
--------------
    trunk/blender/release/scripts/DirectX8Exporter.py
    trunk/blender/release/scripts/uvcalc_lightmap.py
    trunk/blender/release/scripts/wizard_curve2tree.py

Modified: trunk/blender/release/scripts/DirectX8Exporter.py
===================================================================
--- trunk/blender/release/scripts/DirectX8Exporter.py   2008-10-21 08:53:39 UTC 
(rev 17146)
+++ trunk/blender/release/scripts/DirectX8Exporter.py   2008-10-21 09:08:46 UTC 
(rev 17147)
@@ -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__ = """\

Modified: trunk/blender/release/scripts/uvcalc_lightmap.py
===================================================================
--- trunk/blender/release/scripts/uvcalc_lightmap.py    2008-10-21 08:53:39 UTC 
(rev 17146)
+++ trunk/blender/release/scripts/uvcalc_lightmap.py    2008-10-21 09:08:46 UTC 
(rev 17147)
@@ -47,6 +47,12 @@
        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 @@
                        # 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

Modified: trunk/blender/release/scripts/wizard_curve2tree.py
===================================================================
--- trunk/blender/release/scripts/wizard_curve2tree.py  2008-10-21 08:53:39 UTC 
(rev 17146)
+++ trunk/blender/release/scripts/wizard_curve2tree.py  2008-10-21 09:08:46 UTC 
(rev 17147)
@@ -61,6 +61,12 @@
        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 @@
                # 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 @@
                                
                                # 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 @@
                
                # 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):


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to