diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-10-22 11:04:30 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-10-22 11:04:30 +0200 |
commit | 33fa178eeb7bf519f5fff118ebc8e27e76098363 (patch) | |
tree | ab4e5789aa334688d71504d532312fb4ce572b71 /lib/git/objects/base.py | |
parent | 3c9f55dd8e6697ab2f9eaf384315abd4cbefad38 (diff) | |
download | gitpython-33fa178eeb7bf519f5fff118ebc8e27e76098363.tar.gz |
added Object.data_stream property allowing to stream object data directly.Considering the implementation of the git commnd which temporarily keeps it in a cache, it doesnt make a huge diffence as the data is kept in memory while streaming. Only good thing is that it is in a different process so python will never see it if done properly
Diffstat (limited to 'lib/git/objects/base.py')
-rw-r--r-- | lib/git/objects/base.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/git/objects/base.py b/lib/git/objects/base.py index ab1da7b0..dd67a3c7 100644 --- a/lib/git/objects/base.py +++ b/lib/git/objects/base.py @@ -16,6 +16,9 @@ class Object(LazyMixin): This Object also serves as a constructor for instances of the correct type:: inst = Object.new(repo,id) + inst.id # objects sha in hex + inst.size # objects uncompressed data size + inst.data # byte string containing the whole data of the object """ TYPES = ("blob", "tree", "commit", "tag") __slots__ = ("repo", "id", "size", "data" ) @@ -115,6 +118,15 @@ class Object(LazyMixin): """ return '<git.%s "%s">' % (self.__class__.__name__, self.id) + @property + def data_stream(self): + """ + Returns + File Object compatible stream to the uncompressed raw data of the object + """ + proc = self.repo.git.cat_file(self.type, self.id, as_process=True) + return utils.ProcessStreamAdapter(proc, "stdout") + class IndexObject(Object): """ |