summaryrefslogtreecommitdiff
path: root/lib/git/utils.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-06-15 15:18:28 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-06-15 15:18:28 +0200
commite837b901dcfac82e864f806c80f4a9cbfdb9c9f3 (patch)
tree9b9c285df9010e0854d42c077548b8f81d4cdfb8 /lib/git/utils.py
parent1d2307532d679393ae067326e4b6fa1a2ba5cc06 (diff)
downloadgitpython-e837b901dcfac82e864f806c80f4a9cbfdb9c9f3.tar.gz
Move LazyMixin type to gitdb, index reading now uses file_contents_ro from gitdb as well
Diffstat (limited to 'lib/git/utils.py')
-rw-r--r--lib/git/utils.py34
1 files changed, 3 insertions, 31 deletions
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::