Returns the result of calling the method 'method_name' on class 'class' if the class defined such a method, otherwise returns None.
(cls, method_name)
| 480 | |
| 481 | |
| 482 | def __call_cls_method_if_exists(cls, method_name): |
| 483 | """Returns the result of calling the method 'method_name' on class 'class' if the class |
| 484 | defined such a method, otherwise returns None. |
| 485 | """ |
| 486 | method = getattr(cls, method_name, None) |
| 487 | if method: |
| 488 | return method() |
| 489 | |
| 490 | |
| 491 | @contextlib.contextmanager |