1"""Private utility methods used by the subset modules""" 2 3 4def _add_method(*clazzes): 5 """Returns a decorator function that adds a new method to one or 6 more classes.""" 7 8 def wrapper(method): 9 done = [] 10 for clazz in clazzes: 11 if clazz in done: 12 continue # Support multiple names of a clazz 13 done.append(clazz) 14 assert clazz.__name__ != "DefaultTable", "Oops, table class not found." 15 assert not hasattr( 16 clazz, method.__name__ 17 ), "Oops, class '%s' has method '%s'." % (clazz.__name__, method.__name__) 18 setattr(clazz, method.__name__, method) 19 return None 20 21 return wrapper 22 23 24def _uniq_sort(l): 25 return sorted(set(l)) 26