diff options
Diffstat (limited to 'lib/git/remote.py')
-rw-r--r-- | lib/git/remote.py | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/lib/git/remote.py b/lib/git/remote.py index 52dd787d..135e37d7 100644 --- a/lib/git/remote.py +++ b/lib/git/remote.py @@ -7,7 +7,8 @@ from exc import GitCommandError from objects import Commit -from ConfigParser import NoOptionError +from ConfigParser import NoOptionError +from config import SectionConstraint from git.util import ( LazyMixin, @@ -30,29 +31,6 @@ import os __all__ = ('RemoteProgress', 'PushInfo', 'FetchInfo', 'Remote') -class _SectionConstraint(object): - """Constrains a ConfigParser to only option commands which are constrained to - always use the section we have been initialized with. - - It supports all ConfigParser methods that operate on an option""" - __slots__ = ("_config", "_section_name") - _valid_attrs_ = ("get_value", "set_value", "get", "set", "getint", "getfloat", "getboolean", "has_option") - - def __init__(self, config, section): - self._config = config - self._section_name = section - - def __getattr__(self, attr): - if attr in self._valid_attrs_: - return lambda *args, **kwargs: self._call_config(attr, *args, **kwargs) - return super(_SectionConstraint,self).__getattribute__(attr) - - def _call_config(self, method, *args, **kwargs): - """Call the configuration at the given method which must take a section name - as first argument""" - return getattr(self._config, method)(self._section_name, *args, **kwargs) - - class RemoteProgress(object): """ Handler providing an interface to parse progress information emitted by git-push @@ -449,7 +427,7 @@ class Remote(LazyMixin, Iterable): def _set_cache_(self, attr): if attr == "_config_reader": - self._config_reader = _SectionConstraint(self.repo.config_reader(), self._config_section_name()) + self._config_reader = SectionConstraint(self.repo.config_reader(), self._config_section_name()) else: super(Remote, self)._set_cache_(attr) @@ -735,4 +713,4 @@ class Remote(LazyMixin, Iterable): # clear our cache to assure we re-read the possibly changed configuration del(self._config_reader) - return _SectionConstraint(writer, self._config_section_name()) + return SectionConstraint(writer, self._config_section_name()) |