f | def sizer(cls): | f | def sizer(cls): |
| | | |
| def get_size(self): | | def get_size(self): |
n | if hasattr(self, '_custom_size'): | n | if hasattr(self, '_size'): |
| return self._custom_size | | return self._size |
| | | else: |
| try: | | try: |
| return len(self) | | return len(self) |
| except Exception: | | except TypeError: |
| pass | | |
| try: | | try: |
| return abs(self) | | return abs(self) |
| except Exception: | | except TypeError: |
| return 0 | | return 0 |
| | | |
| def set_size(self, value): | | def set_size(self, value): |
n | self._custom_size = value | n | self._size = value |
| | | |
| def del_size(self): | | def del_size(self): |
t | if hasattr(self, '_custom_size'): | t | if hasattr(self, '_size'): |
| del self._custom_size | | del self._size |
| setattr(cls, 'size', property(get_size, set_size, del_size)) | | setattr(cls, 'size', property(get_size, set_size, del_size)) |
| return cls | | return cls |