1212from commit import Commit
1313
1414class Blob (object ):
15+ """A Blob encapsulates a git blob object"""
1516DEFAULT_MIME_TYPE = "text/plain"
1617
1718def __init__ (self ,repo ,id ,mode = None ,name = None ):
@@ -48,6 +49,9 @@ def size(self):
4849
4950 Returns
5051 int
52+
53+ NOTE
54+ The size will be cached after the first access
5155 """
5256if self ._size is None :
5357self ._size = int (self .repo .git .cat_file (self .id ,s = True ).rstrip ())
@@ -60,6 +64,9 @@ def data(self):
6064
6165 Returns
6266 str
67+
68+ NOTE
69+ The data will be cached after the first access.
6370 """
6471self .data_stored = self .data_stored or self .repo .git .cat_file (self .id ,p = True ,with_raw_output = True )
6572return self .data_stored
@@ -71,6 +78,9 @@ def mime_type(self):
7178
7279 Returns
7380 str
81+
82+ NOTE
83+ Defaults to 'text/plain' in case the actual file type is unknown.
7484 """
7585guesses = None
7686if self .name :
@@ -79,6 +89,10 @@ def mime_type(self):
7989
8090@property
8191def basename (self ):
92+ """
93+ Returns
94+ The basename of the Blobs file name
95+ """
8296return os .path .basename (self .name )
8397
8498@classmethod
@@ -88,6 +102,9 @@ def blame(cls, repo, commit, file):
88102
89103 Returns
90104 list: [git.Commit, list: [<line>]]
105+ A list of tuples associating a Commit object with a list of lines that
106+ changed within the given commit. The Commit objects will be given in order
107+ of appearance.
91108 """
92109data = repo .git .blame (commit ,'--' ,file ,p = True )
93110commits = {}