From e837b901dcfac82e864f806c80f4a9cbfdb9c9f3 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 15 Jun 2010 15:18:28 +0200 Subject: Move LazyMixin type to gitdb, index reading now uses file_contents_ro from gitdb as well --- lib/git/utils.py | 34 +++------------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) (limited to 'lib/git/utils.py') diff --git a/lib/git/utils.py b/lib/git/utils.py index 343338a9..bd7cc0f3 100644 --- a/lib/git/utils.py +++ b/lib/git/utils.py @@ -13,7 +13,9 @@ from gitdb.util import ( stream_copy, make_sha, FDStreamWrapper, - LockedFD + LockedFD, + file_contents_ro, + LazyMixin ) @@ -274,36 +276,6 @@ class BlockingLockFile(LockFile): # END endless loop -class LazyMixin(object): - """ - Base class providing an interface to lazily retrieve attribute values upon - first access. If slots are used, memory will only be reserved once the attribute - is actually accessed and retrieved the first time. All future accesses will - return the cached value as stored in the Instance's dict or slot. - """ - __slots__ = tuple() - - def __getattr__(self, attr): - """ - Whenever an attribute is requested that we do not know, we allow it - to be created and set. Next time the same attribute is reqeusted, it is simply - returned from our dict/slots. - """ - self._set_cache_(attr) - # will raise in case the cache was not created - return object.__getattribute__(self, attr) - - def _set_cache_(self, attr): - """ This method should be overridden in the derived class. - It should check whether the attribute named by attr can be created - and cached. Do nothing if you do not know the attribute or call your subclass - - The derived class may create as many additional attributes as it deems - necessary in case a git command returns more information than represented - in the single attribute.""" - pass - - class IterableList(list): """ List of iterable objects allowing to query an object by id or by named index:: -- cgit v1.2.1