From f5d11b750ecc982541d1f936488248f0b42d75d3 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 20:15:50 +0100 Subject: pep8 linting (whitespaces) W191 indentation contains tabs E221 multiple spaces before operator E222 multiple spaces after operator E225 missing whitespace around operator E271 multiple spaces after keyword W292 no newline at end of file W293 blank line contains whitespace W391 blank line at end of file --- git/objects/base.py | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'git/objects/base.py') diff --git a/git/objects/base.py b/git/objects/base.py index 03b22863..9e73e2f3 100644 --- a/git/objects/base.py +++ b/git/objects/base.py @@ -12,7 +12,7 @@ from gitdb.util import ( ) import gitdb.typ as dbtyp - + _assertion_msg_format = "Created object %r whose python type %r disagrees with the acutal git object type %r" __all__ = ("Object", "IndexObject") @@ -21,17 +21,17 @@ class Object(LazyMixin): """Implements an Object which may be Blobs, Trees, Commits and Tags""" NULL_HEX_SHA = '0'*40 NULL_BIN_SHA = '\0'*20 - + TYPES = (dbtyp.str_blob_type, dbtyp.str_tree_type, dbtyp.str_commit_type, dbtyp.str_tag_type) __slots__ = ("repo", "binsha", "size" ) type = None # to be set by subclass - + def __init__(self, repo, binsha): """Initialize an object by identifying it by its binary sha. All keyword arguments will be set on demand if None. - + :param repo: repository this object is located in - + :param binsha: 20 byte SHA1""" super(Object,self).__init__() self.repo = repo @@ -44,13 +44,13 @@ class Object(LazyMixin): :return: New Object instance of a type appropriate to the object type behind id. The id of the newly created object will be a binsha even though the input id may have been a Reference or Rev-Spec - + :param id: reference, rev-spec, or hexsha - + :note: This cannot be a __new__ method as it would always call __init__ with the input id which is not necessarily a binsha.""" return repo.rev_parse(str(id)) - + @classmethod def new_from_sha(cls, repo, sha1): """ @@ -65,36 +65,36 @@ class Object(LazyMixin): inst = get_object_type_by_name(oinfo.type)(repo, oinfo.binsha) inst.size = oinfo.size return inst - + def _set_cache_(self, attr): """Retrieve object information""" - if attr == "size": + if attr == "size": oinfo = self.repo.odb.info(self.binsha) self.size = oinfo.size # assert oinfo.type == self.type, _assertion_msg_format % (self.binsha, oinfo.type, self.type) else: super(Object,self)._set_cache_(attr) - + def __eq__(self, other): """:return: True if the objects have the same SHA1""" if not hasattr(other, 'binsha'): return False return self.binsha == other.binsha - + def __ne__(self, other): """:return: True if the objects do not have the same SHA1 """ if not hasattr(other, 'binsha'): return True return self.binsha != other.binsha - + def __hash__(self): """:return: Hash of our id allowing objects to be used in dicts and sets""" return hash(self.binsha) - + def __str__(self): """:return: string of our SHA1 as understood by all git commands""" return bin_to_hex(self.binsha) - + def __repr__(self): """:return: string with pythonic representation of our object""" return '' % (self.__class__.__name__, self.hexsha) @@ -117,16 +117,16 @@ class Object(LazyMixin): istream = self.repo.odb.stream(self.binsha) stream_copy(istream, ostream) return self - + class IndexObject(Object): """Base for all objects that can be part of the index file , namely Tree, Blob and SubModule objects""" __slots__ = ("path", "mode") - + # for compatability with iterable lists _id_attribute_ = 'path' - + def __init__(self, repo, binsha, mode=None, path=None): """Initialize a newly instanced IndexObject :param repo: is the Repo we are located in @@ -144,13 +144,13 @@ class IndexObject(Object): self.mode = mode if path is not None: self.path = path - + def __hash__(self): """:return: Hash of our path as index items are uniquely identifyable by path, not by their data !""" return hash(self.path) - + def _set_cache_(self, attr): if attr in IndexObject.__slots__: # they cannot be retrieved lateron ( not without searching for them ) @@ -158,19 +158,18 @@ class IndexObject(Object): else: super(IndexObject, self)._set_cache_(attr) # END hanlde slot attribute - + @property def name(self): """:return: Name portion of the path, effectively being the basename""" return basename(self.path) - + @property def abspath(self): """ :return: Absolute path to this index object in the file system ( as opposed to the .path field which is a path relative to the git repository ). - + The returned path will be native to the system and contains '\' on windows. """ return join_path_native(self.repo.working_tree_dir, self.path) - -- cgit v1.2.3 From be34ec23c48d6d5d8fd2ef4491981f6fb4bab8e6 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 20:51:04 +0100 Subject: pep8 linting (blank lines expectations) E301 expected 1 blank line, found 0 E302 expected 2 blank lines, found 1 E303 too many blank lines (n) --- git/objects/base.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'git/objects/base.py') diff --git a/git/objects/base.py b/git/objects/base.py index 9e73e2f3..fce41a3d 100644 --- a/git/objects/base.py +++ b/git/objects/base.py @@ -17,7 +17,9 @@ _assertion_msg_format = "Created object %r whose python type %r disagrees with t __all__ = ("Object", "IndexObject") + class Object(LazyMixin): + """Implements an Object which may be Blobs, Trees, Commits and Tags""" NULL_HEX_SHA = '0'*40 NULL_BIN_SHA = '\0'*20 @@ -120,6 +122,7 @@ class Object(LazyMixin): class IndexObject(Object): + """Base for all objects that can be part of the index file , namely Tree, Blob and SubModule objects""" __slots__ = ("path", "mode") -- cgit v1.2.3 From 614907b7445e2ed8584c1c37df7e466e3b56170f Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 20:56:53 +0100 Subject: pep8 linting (whitespace before/after) E201 whitespace after '(' E202 whitespace before ')' E203 whitespace before ':' E225 missing whitespace around operator E226 missing whitespace around arithmetic operator E227 missing whitespace around bitwise or shift operator E228 missing whitespace around modulo operator E231 missing whitespace after ',' E241 multiple spaces after ',' E251 unexpected spaces around keyword / parameter equals --- git/objects/base.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'git/objects/base.py') diff --git a/git/objects/base.py b/git/objects/base.py index fce41a3d..d7c92d8a 100644 --- a/git/objects/base.py +++ b/git/objects/base.py @@ -21,11 +21,11 @@ __all__ = ("Object", "IndexObject") class Object(LazyMixin): """Implements an Object which may be Blobs, Trees, Commits and Tags""" - NULL_HEX_SHA = '0'*40 - NULL_BIN_SHA = '\0'*20 + NULL_HEX_SHA = '0' * 40 + NULL_BIN_SHA = '\0' * 20 TYPES = (dbtyp.str_blob_type, dbtyp.str_tree_type, dbtyp.str_commit_type, dbtyp.str_tag_type) - __slots__ = ("repo", "binsha", "size" ) + __slots__ = ("repo", "binsha", "size") type = None # to be set by subclass def __init__(self, repo, binsha): @@ -35,7 +35,7 @@ class Object(LazyMixin): :param repo: repository this object is located in :param binsha: 20 byte SHA1""" - super(Object,self).__init__() + super(Object, self).__init__() self.repo = repo self.binsha = binsha assert len(binsha) == 20, "Require 20 byte binary sha, got %r, len = %i" % (binsha, len(binsha)) @@ -75,7 +75,7 @@ class Object(LazyMixin): self.size = oinfo.size # assert oinfo.type == self.type, _assertion_msg_format % (self.binsha, oinfo.type, self.type) else: - super(Object,self)._set_cache_(attr) + super(Object, self)._set_cache_(attr) def __eq__(self, other): """:return: True if the objects have the same SHA1""" @@ -157,7 +157,7 @@ class IndexObject(Object): def _set_cache_(self, attr): if attr in IndexObject.__slots__: # they cannot be retrieved lateron ( not without searching for them ) - raise AttributeError( "path and mode attributes must have been set during %s object creation" % type(self).__name__ ) + raise AttributeError("path and mode attributes must have been set during %s object creation" % type(self).__name__) else: super(IndexObject, self)._set_cache_(attr) # END hanlde slot attribute -- cgit v1.2.3 From c8e70749887370a99adeda972cc3503397b5f9a7 Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Sun, 16 Nov 2014 21:09:47 +0100 Subject: pep8 linting (trailing whitespace) W291 trailing whitespace --- git/objects/base.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'git/objects/base.py') diff --git a/git/objects/base.py b/git/objects/base.py index d7c92d8a..0fcd25d6 100644 --- a/git/objects/base.py +++ b/git/objects/base.py @@ -29,7 +29,7 @@ class Object(LazyMixin): type = None # to be set by subclass def __init__(self, repo, binsha): - """Initialize an object by identifying it by its binary sha. + """Initialize an object by identifying it by its binary sha. All keyword arguments will be set on demand if None. :param repo: repository this object is located in @@ -43,8 +43,8 @@ class Object(LazyMixin): @classmethod def new(cls, repo, id): """ - :return: New Object instance of a type appropriate to the object type behind - id. The id of the newly created object will be a binsha even though + :return: New Object instance of a type appropriate to the object type behind + id. The id of the newly created object will be a binsha even though the input id may have been a Reference or Rev-Spec :param id: reference, rev-spec, or hexsha @@ -56,7 +56,7 @@ class Object(LazyMixin): @classmethod def new_from_sha(cls, repo, sha1): """ - :return: new object instance of a type appropriate to represent the given + :return: new object instance of a type appropriate to represent the given binary sha1 :param sha1: 20 byte binary sha1""" if sha1 == cls.NULL_BIN_SHA: @@ -66,7 +66,7 @@ class Object(LazyMixin): oinfo = repo.odb.info(sha1) inst = get_object_type_by_name(oinfo.type)(repo, oinfo.binsha) inst.size = oinfo.size - return inst + return inst def _set_cache_(self, attr): """Retrieve object information""" @@ -150,7 +150,7 @@ class IndexObject(Object): def __hash__(self): """:return: - Hash of our path as index items are uniquely identifyable by path, not + Hash of our path as index items are uniquely identifyable by path, not by their data !""" return hash(self.path) @@ -171,7 +171,7 @@ class IndexObject(Object): def abspath(self): """ :return: - Absolute path to this index object in the file system ( as opposed to the + Absolute path to this index object in the file system ( as opposed to the .path field which is a path relative to the git repository ). The returned path will be native to the system and contains '\' on windows. """ -- cgit v1.2.3