Make _add_method fail gracefully

This commit is contained in:
Shadowfacts 2025-02-11 14:06:48 -05:00
parent 1787cf63cf
commit d6f40c2e45

View File

@ -12,10 +12,8 @@ def _add_method(*clazzes):
continue # Support multiple names of a clazz continue # Support multiple names of a clazz
done.append(clazz) done.append(clazz)
assert clazz.__name__ != "DefaultTable", "Oops, table class not found." assert clazz.__name__ != "DefaultTable", "Oops, table class not found."
assert not hasattr( if not hasattr(clazz, method.__name__):
clazz, method.__name__ setattr(clazz, method.__name__, method)
), "Oops, class '%s' has method '%s'." % (clazz.__name__, method.__name__)
setattr(clazz, method.__name__, method)
return None return None
return wrapper return wrapper