Changeset 308

Show
Ignore:
Timestamp:
02/25/08 14:05:22 (5 years ago)
Author:
ged
Message:

Nth take at making Elixir python2.3 compatible

Location:
elixir/trunk/elixir
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • elixir/trunk/elixir/entity.py

    r307 r308  
    44''' 
    55 
    6 from py23compat import set, rsplit 
     6from py23compat import set, rsplit, sorted 
    77 
    88import sys 
  • elixir/trunk/elixir/py23compat.py

    r307 r308  
    1313    # global name 'sorted' doesn't exist in Python2.3 
    1414    # this provides a poor-man's emulation of the sorted built-in method 
    15     def sorted(l, kwargs): 
    16         if 'key' not in kwargs: 
    17             raise Exception('Our python 2.3 version of sorted needs a key kwarg argument') 
    18         key_func = kwargs['key'] 
     15    def sorted(l, **kwargs): 
    1916        sorted_list = list(l) 
    20         sorted_list.sort(lambda self, other: cmp(key_func(self), 
    21                                                  key_func(other))) 
     17        if 'key' in kwargs: 
     18            key_func = kwargs['key'] 
     19            sorted_list.sort(lambda self, other: cmp(key_func(self), 
     20                                                     key_func(other))) 
     21        else: 
     22            sorted_list.sort() 
    2223        return sorted_list 
    2324