diff options
Diffstat (limited to 'lib/git')
-rw-r--r-- | lib/git/cmd.py | 10 | ||||
-rw-r--r-- | lib/git/method_missing.py | 26 |
2 files changed, 7 insertions, 29 deletions
diff --git a/lib/git/cmd.py b/lib/git/cmd.py index a6e8f6cc..38cfe3bd 100644 --- a/lib/git/cmd.py +++ b/lib/git/cmd.py @@ -8,7 +8,6 @@ import os import subprocess import re from utils import * -from method_missing import MethodMissingMixin from errors import GitCommandError # Enables debugging of GitPython's git commands @@ -17,7 +16,7 @@ GIT_PYTHON_TRACE = os.environ.get("GIT_PYTHON_TRACE", False) execute_kwargs = ('istream', 'with_keep_cwd', 'with_extended_output', 'with_exceptions', 'with_raw_output') -class Git(MethodMissingMixin): +class Git(object): """ The Git class manages communication with the Git binary """ @@ -25,6 +24,11 @@ class Git(MethodMissingMixin): super(Git, self).__init__() self.git_dir = git_dir + def __getattr__(self, name): + if name[:1] == '_': + raise AttributeError(name) + return lambda *args, **kwargs: self._call_process(name, *args, **kwargs) + @property def get_dir(self): return self.git_dir @@ -131,7 +135,7 @@ class Git(MethodMissingMixin): args.append("--%s=%s" % (dashify(k), v)) return args - def method_missing(self, method, *args, **kwargs): + def _call_process(self, method, *args, **kwargs): """ Run the given git command with the specified arguments and return the result as a String diff --git a/lib/git/method_missing.py b/lib/git/method_missing.py deleted file mode 100644 index 250fcc6d..00000000 --- a/lib/git/method_missing.py +++ /dev/null @@ -1,26 +0,0 @@ -# method_missing.py -# Copyright (C) 2008 Michael Trier (mtrier@gmail.com) and contributors -# Portions derived from http://blog.iffy.us/?p=43 -# -# This module is part of GitPython and is released under -# the BSD License: http://www.opensource.org/licenses/bsd-license.php - -class MethodMissingMixin(object): - """ - A Mixin' to implement the 'method_missing' Ruby-like protocol. - - Ideas were `taken from the following blog post - <http://blog.iffy.us/?p=43>`_ - """ - def __getattr__(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. """ - raise NotImplementedError(str(self.__wrapped__) + " 'method_missing' method has not been implemented.") |