diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-10-11 11:01:12 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-10-11 11:01:12 +0200 |
commit | 9ee31065abea645cbc2cf3e54b691d5983a228b2 (patch) | |
tree | 21e38d54e5a69d2983906f6ac30e6322ed9a7ef1 /lib/git/blob.py | |
parent | 8430529e1a9fb28d8586d24ee507a8195c370fa5 (diff) | |
download | gitpython-9ee31065abea645cbc2cf3e54b691d5983a228b2.tar.gz |
Intermediate commit: commit,tree and blob objects now derive from object - test is in place which still fails on purpose. Need to integrate tags which can be objects or just a special form of a ref
Diffstat (limited to 'lib/git/blob.py')
-rw-r--r-- | lib/git/blob.py | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/lib/git/blob.py b/lib/git/blob.py index 1e8aa12b..3ecd3a38 100644 --- a/lib/git/blob.py +++ b/lib/git/blob.py @@ -10,10 +10,13 @@ import re import time from actor import Actor from commit import Commit +import base -class Blob(object): +class Blob(base.Object): """A Blob encapsulates a git blob object""" DEFAULT_MIME_TYPE = "text/plain" + type = "blob" + __slots__ = ("mode", "path", "_data_stored") # precompiled regex re_whitespace = re.compile(r'\s+') @@ -40,28 +43,10 @@ class Blob(object): Returns git.Blob """ - self.repo = repo - self.id = id + super(Blob,self).__init__(repo, id, "blob") self.mode = mode self.path = path - - self._size = None - self.data_stored = None - - @property - def size(self): - """ - The size of this blob in bytes - - Returns - int - - NOTE - The size will be cached after the first access - """ - if self._size is None: - self._size = int(self.repo.git.cat_file(self.id, s=True).rstrip()) - return self._size + self._data_stored = None @property def data(self): @@ -74,8 +59,8 @@ class Blob(object): NOTE The data will be cached after the first access. """ - self.data_stored = self.data_stored or self.repo.git.cat_file(self.id, p=True, with_raw_output=True) - return self.data_stored + self._data_stored = self._data_stored or self.repo.git.cat_file(self.id, p=True, with_raw_output=True) + return self._data_stored @property def mime_type(self): |