diff options
author | Campbell Barton <ideasman42@gmail.com> | 2008-10-21 13:08:46 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2008-10-21 13:08:46 +0400 |
commit | 1df683a38be5c092f1e2a3da693a174a3ad78373 (patch) | |
tree | 5d2d77737413c332dc1e8563a47e7a6d888ab53c | |
parent | f99c02a06b8ee8e43b6811f27591993e91e1557a (diff) |
more python 2.3 compat, should be the last of it.
-rw-r--r-- | release/scripts/DirectX8Exporter.py | 2 | ||||
-rw-r--r-- | release/scripts/uvcalc_lightmap.py | 11 | ||||
-rw-r--r-- | release/scripts/wizard_curve2tree.py | 26 |
3 files changed, 30 insertions, 9 deletions
diff --git a/release/scripts/DirectX8Exporter.py b/release/scripts/DirectX8Exporter.py index 01212545f77..b8bdae4de2b 100644 --- a/release/scripts/DirectX8Exporter.py +++ b/release/scripts/DirectX8Exporter.py @@ -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__ = """\ diff --git a/release/scripts/uvcalc_lightmap.py b/release/scripts/uvcalc_lightmap.py index 37423b7197e..1433ccbd13a 100644 --- a/release/scripts/uvcalc_lightmap.py +++ b/release/scripts/uvcalc_lightmap.py @@ -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 diff --git a/release/scripts/wizard_curve2tree.py b/release/scripts/wizard_curve2tree.py index 84b2cc76132..1965f9a5070 100644 --- a/release/scripts/wizard_curve2tree.py +++ b/release/scripts/wizard_curve2tree.py @@ -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): |