| Total Complexity | 8 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | class Class_Operation(object): |
||
| 2 | """ |
||
| 3 | Class Operation |
||
| 4 | """ |
||
| 5 | |||
| 6 | def __init__(self, operation, cls1, cls2): |
||
| 7 | """ |
||
| 8 | """ |
||
| 9 | self.cls1 = cls1 |
||
| 10 | self.cls2 = cls2 |
||
| 11 | self._operation = operation |
||
| 12 | |||
| 13 | def __getattr__(self, attr): |
||
| 14 | try: |
||
| 15 | return getattr(getattr(self.cls1, attr), |
||
| 16 | self._operation)(getattr(self.cls2, attr)) |
||
| 17 | except AttributeError: |
||
| 18 | return lambda *args: getattr( |
||
| 19 | getattr(self.cls1, attr)(*args), |
||
| 20 | self._operation)(getattr(self.cls2, attr)(*args)) |
||
| 21 | |||
| 22 | def __add__(self, other): |
||
| 23 | return Class_Operation('__add__', self, other) |
||
| 24 | |||
| 25 | def __sub__(self, other): |
||
| 26 | return Class_Operation('__sub__', self, other) |
||
| 27 | |||
| 28 | def __mul__(self, other): |
||
| 29 | return Class_Operation('__mul__', self, other) |
||
| 30 | |||
| 31 | def __gt__(self, other): |
||
| 32 | return Class_Operation('__gt__', self, other) |
||
| 33 |