| |   |
| 5 | 5 | This was `taken from a blog post <http://blog.iffy.us/?p=43>`_ |
| 6 | 6 | """ |
| 7 | 7 | def __getattr__(self, attr): |
| 8 | | try: |
| 9 | | return object.__getattribute__(self, attr) |
| 10 | | except: |
| 11 | | class MethodMissing(object): |
| 12 | | def __init__(self, wrapped, method): |
| 13 | | self.__wrapped__ = wrapped |
| 14 | | self.__method__ = method |
| 15 | | def __call__(self, *args, **kwargs): |
| 16 | | return self.__wrapped__.method_missing(self.__method__, *args, **kwargs) |
| 17 | | return MethodMissing(self, attr) |
| 8 | class MethodMissing(object): |
| 9 | def __init__(self, wrapped, method): |
| 10 | self.__wrapped__ = wrapped |
| 11 | self.__method__ = method |
| 12 | def __call__(self, *args, **kwargs): |
| 13 | return self.__wrapped__.method_missing(self.__method__, *args, **kwargs) |
| 14 | return MethodMissing(self, attr) |
| 18 | 15 | |
| 19 | 16 | def method_missing(self, *args, **kwargs): |
| 20 | 17 | """ This method should be overridden in the derived class. """ |
| toggle raw diff |
--- a/lib/git/method_missing.py
+++ b/lib/git/method_missing.py
@@ -5,16 +5,13 @@ class MethodMissingMixin(object):
This was `taken from a blog post <http://blog.iffy.us/?p=43>`_
"""
def __getattr__(self, attr):
- try:
- return object.__getattribute__(self, attr)
- except:
- class MethodMissing(object):
- def __init__(self, wrapped, method):
- self.__wrapped__ = wrapped
- self.__method__ = method
- def __call__(self, *args, **kwargs):
- return self.__wrapped__.method_missing(self.__method__, *args, **kwargs)
- return MethodMissing(self, attr)
+ class MethodMissing(object):
+ def __init__(self, wrapped, method):
+ self.__wrapped__ = wrapped
+ self.__method__ = method
+ def __call__(self, *args, **kwargs):
+ return self.__wrapped__.method_missing(self.__method__, *args, **kwargs)
+ return MethodMissing(self, attr)
def method_missing(self, *args, **kwargs):
""" This method should be overridden in the derived class. """ |