diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2014-11-17 10:14:43 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2014-11-17 10:14:43 +0100 |
commit | e4d8fb73daa82420bdc69c37f0d58f7cb4cd505a (patch) | |
tree | 38e1241fd6d756f783b6b56dc6628ac3ca41ed4f /git/index/typ.py | |
parent | 7aba59a2609ec768d5d495dafd23a4bce8179741 (diff) | |
parent | c8e70749887370a99adeda972cc3503397b5f9a7 (diff) | |
download | gitpython-e4d8fb73daa82420bdc69c37f0d58f7cb4cd505a.tar.gz |
Merge pull request #204 from hashar/pep8-linting
Pep8 linting
Diffstat (limited to 'git/index/typ.py')
-rw-r--r-- | git/index/typ.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/git/index/typ.py b/git/index/typ.py index 7f27d869..4a6f6a81 100644 --- a/git/index/typ.py +++ b/git/index/typ.py @@ -1,7 +1,7 @@ """Module with additional types used by the index""" from util import ( - pack, + pack, unpack ) @@ -21,7 +21,9 @@ CE_STAGESHIFT = 12 #} END invariants + class BlobFilter(object): + """ Predicate to be used by iter_blobs allowing to filter only return blobs which match the given list of directories or files. @@ -47,6 +49,7 @@ class BlobFilter(object): class BaseIndexEntry(tuple): + """Small Brother of an index entry which can be created to describe changes done to the index in which case plenty of additional information is not requried. @@ -56,7 +59,7 @@ class BaseIndexEntry(tuple): def __str__(self): return "%o %s %i\t%s" % (self.mode, self.hexsha, self.stage, self.path) - + def __repr__(self): return "(%o, %s, %i, %s)" % (self.mode, self.hexsha, self.stage, self.path) @@ -69,7 +72,7 @@ class BaseIndexEntry(tuple): def binsha(self): """binary sha of the blob """ return self[1] - + @property def hexsha(self): """hex version of our sha""" @@ -78,12 +81,12 @@ class BaseIndexEntry(tuple): @property def stage(self): """Stage of the entry, either: - + * 0 = default stage * 1 = stage before a merge or common ancestor entry in case of a 3 way merge * 2 = stage of entries from the 'left' side of the merge * 3 = stage of entries from the right side of the merge - + :note: For more information, see http://www.kernel.org/pub/software/scm/git/docs/git-read-tree.html """ return (self[2] & CE_STAGEMASK) >> CE_STAGESHIFT @@ -99,16 +102,17 @@ class BaseIndexEntry(tuple): return self[2] @classmethod - def from_blob(cls, blob, stage = 0): + def from_blob(cls, blob, stage=0): """:return: Fully equipped BaseIndexEntry at the given stage""" return cls((blob.mode, blob.binsha, stage << CE_STAGESHIFT, blob.path)) - + def to_blob(self, repo): """:return: Blob using the information of this index entry""" - return Blob(repo, self.binsha, self.mode, self.path) + return Blob(repo, self.binsha, self.mode, self.path) class IndexEntry(BaseIndexEntry): + """Allows convenient access to IndexEntry data without completely unpacking it. Attributes usully accessed often are cached in the tuple whereas others are @@ -152,10 +156,10 @@ class IndexEntry(BaseIndexEntry): def size(self): """:return: Uncompressed size of the blob """ return self[10] - + @classmethod def from_base(cls, base): - """ + """ :return: Minimal entry as created from the given BaseIndexEntry instance. Missing values will be set to null-like values @@ -165,9 +169,7 @@ class IndexEntry(BaseIndexEntry): return IndexEntry((base.mode, base.binsha, base.flags, base.path, time, time, 0, 0, 0, 0, 0)) @classmethod - def from_blob(cls, blob, stage = 0): + def from_blob(cls, blob, stage=0): """:return: Minimal entry resembling the given blob object""" time = pack(">LL", 0, 0) return IndexEntry((blob.mode, blob.binsha, stage << CE_STAGESHIFT, blob.path, time, time, 0, 0, 0, 0, blob.size)) - - |