summaryrefslogtreecommitdiff
path: root/git/objects
diff options
context:
space:
mode:
authorAntoine Musso <hashar@free.fr>2014-11-16 20:56:53 +0100
committerAntoine Musso <hashar@free.fr>2014-11-16 21:05:53 +0100
commit614907b7445e2ed8584c1c37df7e466e3b56170f (patch)
tree4b6e09110cd356799e9fa0f188fae55e5fa81fca /git/objects
parentbe34ec23c48d6d5d8fd2ef4491981f6fb4bab8e6 (diff)
downloadgitpython-614907b7445e2ed8584c1c37df7e466e3b56170f.tar.gz
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
Diffstat (limited to 'git/objects')
-rw-r--r--git/objects/__init__.py4
-rw-r--r--git/objects/base.py12
-rw-r--r--git/objects/commit.py16
-rw-r--r--git/objects/fun.py16
-rw-r--r--git/objects/submodule/base.py24
-rw-r--r--git/objects/submodule/root.py38
-rw-r--r--git/objects/submodule/util.py2
-rw-r--r--git/objects/tag.py4
-rw-r--r--git/objects/tree.py26
-rw-r--r--git/objects/util.py38
10 files changed, 90 insertions, 90 deletions
diff --git a/git/objects/__init__.py b/git/objects/__init__.py
index 90fe81a8..5708ac0b 100644
--- a/git/objects/__init__.py
+++ b/git/objects/__init__.py
@@ -17,5 +17,5 @@ from blob import *
from commit import *
from tree import *
-__all__ = [ name for name, obj in locals().items()
- if not (name.startswith('_') or inspect.ismodule(obj)) ]
+__all__ = [name for name, obj in locals().items()
+ if not (name.startswith('_') or inspect.ismodule(obj))]
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
diff --git a/git/objects/commit.py b/git/objects/commit.py
index b2ed02c0..14cf5bbb 100644
--- a/git/objects/commit.py
+++ b/git/objects/commit.py
@@ -64,7 +64,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
def __init__(self, repo, binsha, tree=None, author=None, authored_date=None, author_tz_offset=None,
committer=None, committed_date=None, committer_tz_offset=None,
- message=None, parents=None, encoding=None, gpgsig=None):
+ message=None, parents=None, encoding=None, gpgsig=None):
"""Instantiate a new Commit. All keyword arguments taking None as default will
be implicitly set on first query.
:param binsha: 20 byte sha1
@@ -98,7 +98,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
:note: Timezone information is in the same format and in the same sign
as what time.altzone returns. The sign is inverted compared to git's
UTC timezone."""
- super(Commit,self).__init__(repo, binsha)
+ super(Commit, self).__init__(repo, binsha)
if tree is not None:
assert isinstance(tree, Tree), "Tree needs to be a Tree instance, was %s" % type(tree)
if tree is not None:
@@ -235,7 +235,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
:param proc: git-rev-list process instance - one sha per line
:return: iterator returning Commit objects"""
stream = proc_or_stream
- if not hasattr(stream,'readline'):
+ if not hasattr(stream, 'readline'):
stream = proc_or_stream.stdout
readline = stream.readline
@@ -286,7 +286,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
parents = parent_commits
if parent_commits is None:
try:
- parent_commits = [ repo.head.commit ]
+ parent_commits = [repo.head.commit]
except ValueError:
# empty repositories have no head commit
parent_commits = list()
@@ -400,7 +400,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
if self.gpgsig:
write("gpgsig")
for sigline in self.gpgsig.rstrip("\n").split("\n"):
- write(" "+sigline+"\n")
+ write(" " + sigline + "\n")
write("\n")
@@ -416,7 +416,7 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
""":param from_rev_list: if true, the stream format is coming from the rev-list command
Otherwise it is assumed to be a plain data stream from our object"""
readline = stream.readline
- self.tree = Tree(self.repo, hex_to_bin(readline().split()[1]), Tree.tree_id<<12, '')
+ self.tree = Tree(self.repo, hex_to_bin(readline().split()[1]), Tree.tree_id << 12, '')
self.parents = list()
next_line = None
@@ -449,9 +449,9 @@ class Commit(base.Object, Iterable, Diffable, Traversable, Serializable):
buf = enc.strip()
while buf != "":
if buf[0:10] == "encoding ":
- self.encoding = buf[buf.find(' ')+1:]
+ self.encoding = buf[buf.find(' ') + 1:]
elif buf[0:7] == "gpgsig ":
- sig = buf[buf.find(' ')+1:] + "\n"
+ sig = buf[buf.find(' ') + 1:] + "\n"
is_next_header = False
while True:
sigbuf = readline()
diff --git a/git/objects/fun.py b/git/objects/fun.py
index 8f5a5cc2..0bb14376 100644
--- a/git/objects/fun.py
+++ b/git/objects/fun.py
@@ -15,7 +15,7 @@ def tree_to_stream(entries, write):
for binsha, mode, name in entries:
mode_str = ''
for i in xrange(6):
- mode_str = chr(((mode >> (i*3)) & bit_mask) + ord_zero) + mode_str
+ mode_str = chr(((mode >> (i * 3)) & bit_mask) + ord_zero) + mode_str
# END for each 8 octal value
# git slices away the first octal if its zero
@@ -79,7 +79,7 @@ def tree_entries_from_data(data):
# byte is NULL, get next 20
i += 1
- sha = data[i:i+20]
+ sha = data[i:i + 20]
i = i + 20
out.append((sha, mode, name))
# END for each byte in data stream
@@ -112,7 +112,7 @@ def _to_full_path(item, path_prefix):
"""Rebuild entry with given path prefix"""
if not item:
return item
- return (item[0], item[1], path_prefix+item[2])
+ return (item[0], item[1], path_prefix + item[2])
def traverse_trees_recursive(odb, tree_shas, path_prefix):
@@ -152,7 +152,7 @@ def traverse_trees_recursive(odb, tree_shas, path_prefix):
if not item:
continue
# END skip already done items
- entries = [ None for n in range(nt) ]
+ entries = [None for n in range(nt)]
entries[ti] = item
sha, mode, name = item # its faster to unpack
is_dir = S_ISDIR(mode) # type mode bits
@@ -160,14 +160,14 @@ def traverse_trees_recursive(odb, tree_shas, path_prefix):
# find this item in all other tree data items
# wrap around, but stop one before our current index, hence
# ti+nt, not ti+1+nt
- for tio in range(ti+1, ti+nt):
+ for tio in range(ti + 1, ti + nt):
tio = tio % nt
entries[tio] = _find_by_name(trees_data[tio], name, is_dir, ii)
# END for each other item data
# if we are a directory, enter recursion
if is_dir:
- out.extend(traverse_trees_recursive(odb, [((ei and ei[0]) or None) for ei in entries], path_prefix+name+'/'))
+ out.extend(traverse_trees_recursive(odb, [((ei and ei[0]) or None) for ei in entries], path_prefix + name + '/'))
else:
out_append(tuple(_to_full_path(e, path_prefix) for e in entries))
# END handle recursion
@@ -196,9 +196,9 @@ def traverse_tree_recursive(odb, tree_sha, path_prefix):
# unpacking/packing is faster than accessing individual items
for sha, mode, name in data:
if S_ISDIR(mode):
- entries.extend(traverse_tree_recursive(odb, sha, path_prefix+name+'/'))
+ entries.extend(traverse_tree_recursive(odb, sha, path_prefix + name + '/'))
else:
- entries.append((sha, mode, path_prefix+name))
+ entries.append((sha, mode, path_prefix + name))
# END for each item
return entries
diff --git a/git/objects/submodule/base.py b/git/objects/submodule/base.py
index 42048028..770dcffd 100644
--- a/git/objects/submodule/base.py
+++ b/git/objects/submodule/base.py
@@ -37,7 +37,7 @@ class UpdateProgress(RemoteProgress):
"""Class providing detailed progress information to the caller who should
derive from it and implement the ``update(...)`` message"""
- CLONE, FETCH, UPDWKTREE = [1 << x for x in range(RemoteProgress._num_op_codes, RemoteProgress._num_op_codes+3)]
+ CLONE, FETCH, UPDWKTREE = [1 << x for x in range(RemoteProgress._num_op_codes, RemoteProgress._num_op_codes + 3)]
_num_op_codes = RemoteProgress._num_op_codes + 3
__slots__ = tuple()
@@ -75,7 +75,7 @@ class Submodule(util.IndexObject, Iterable, Traversable):
__slots__ = ('_parent_commit', '_url', '_branch_path', '_name', '__weakref__')
_cache_attrs = ('path', '_url', '_branch_path')
- def __init__(self, repo, binsha, mode=None, path=None, name = None, parent_commit=None, url=None, branch_path=None):
+ def __init__(self, repo, binsha, mode=None, path=None, name=None, parent_commit=None, url=None, branch_path=None):
"""Initialize this instance with its attributes. We only document the ones
that differ from ``IndexObject``
@@ -168,7 +168,7 @@ class Submodule(util.IndexObject, Iterable, Traversable):
raise ValueError("Cannot write blobs of 'historical' submodule configurations")
# END handle writes of historical submodules
- return SubmoduleConfigParser(fp_module, read_only = read_only)
+ return SubmoduleConfigParser(fp_module, read_only=read_only)
def _clear_cache(self):
# clear the possibly changed values
@@ -277,7 +277,7 @@ class Submodule(util.IndexObject, Iterable, Traversable):
url = urls[0]
else:
# clone new repo
- kwargs = {'n' : no_checkout}
+ kwargs = {'n': no_checkout}
if not branch_is_default:
kwargs['b'] = br.name
# END setup checkout-branch
@@ -354,16 +354,16 @@ class Submodule(util.IndexObject, Iterable, Traversable):
op |= BEGIN
#END handle start
- progress.update(op, i, len_rmts, prefix+"Fetching remote %s of submodule %r" % (remote, self.name))
+ progress.update(op, i, len_rmts, prefix + "Fetching remote %s of submodule %r" % (remote, self.name))
#===============================
if not dry_run:
remote.fetch(progress=progress)
#END handle dry-run
#===============================
- if i == len_rmts-1:
+ if i == len_rmts - 1:
op |= END
#END handle end
- progress.update(op, i, len_rmts, prefix+"Done fetching remote of submodule %r" % self.name)
+ progress.update(op, i, len_rmts, prefix + "Done fetching remote of submodule %r" % self.name)
#END fetch new data
except InvalidGitRepositoryError:
if not init:
@@ -383,11 +383,11 @@ class Submodule(util.IndexObject, Iterable, Traversable):
# don't check it out at first - nonetheless it will create a local
# branch according to the remote-HEAD if possible
- progress.update(BEGIN|CLONE, 0, 1, prefix+"Cloning %s to %s in submodule %r" % (self.url, module_path, self.name))
+ progress.update(BEGIN | CLONE, 0, 1, prefix + "Cloning %s to %s in submodule %r" % (self.url, module_path, self.name))
if not dry_run:
mrepo = git.Repo.clone_from(self.url, module_path, n=True)
#END handle dry-run
- progress.update(END|CLONE, 0, 1, prefix+"Done cloning to %s" % module_path)
+ progress.update(END | CLONE, 0, 1, prefix + "Done cloning to %s" % module_path)
if not dry_run:
# see whether we have a valid branch to checkout
@@ -444,7 +444,7 @@ class Submodule(util.IndexObject, Iterable, Traversable):
# update the working tree
# handles dry_run
if mrepo is not None and mrepo.head.commit.binsha != binsha:
- progress.update(BEGIN|UPDWKTREE, 0, 1, prefix+"Updating working tree at %s for submodule %r to revision %s" % (self.path, self.name, hexsha))
+ progress.update(BEGIN | UPDWKTREE, 0, 1, prefix + "Updating working tree at %s for submodule %r to revision %s" % (self.path, self.name, hexsha))
if not dry_run:
if is_detached:
# NOTE: for now we force, the user is no supposed to change detached
@@ -459,7 +459,7 @@ class Submodule(util.IndexObject, Iterable, Traversable):
mrepo.head.reset(hexsha, index=True, working_tree=True)
# END handle checkout
#END handle dry_run
- progress.update(END|UPDWKTREE, 0, 1, prefix+"Done updating working tree for submodule %r" % self.name)
+ progress.update(END | UPDWKTREE, 0, 1, prefix + "Done updating working tree for submodule %r" % self.name)
# END update to new commit only if needed
# HANDLE RECURSION
@@ -557,7 +557,7 @@ class Submodule(util.IndexObject, Iterable, Traversable):
ekey = index.entry_key(self.path, 0)
entry = index.entries[ekey]
del(index.entries[ekey])
- nentry = git.IndexEntry(entry[:3]+(module_path,)+entry[4:])
+ nentry = git.IndexEntry(entry[:3] + (module_path,) + entry[4:])
index.entries[tekey] = nentry
except KeyError:
raise InvalidGitRepositoryError("Submodule's entry at %r did not exist" % (self.path))
diff --git a/git/objects/submodule/root.py b/git/objects/submodule/root.py
index 62ad1f05..b8cc904c 100644
--- a/git/objects/submodule/root.py
+++ b/git/objects/submodule/root.py
@@ -13,8 +13,8 @@ __all__ = ["RootModule", "RootUpdateProgress"]
class RootUpdateProgress(UpdateProgress):
"""Utility class which adds more opcodes to the UpdateProgress"""
- REMOVE, PATHCHANGE, BRANCHCHANGE, URLCHANGE = [1 << x for x in range(UpdateProgress._num_op_codes, UpdateProgress._num_op_codes+4)]
- _num_op_codes = UpdateProgress._num_op_codes+4
+ REMOVE, PATHCHANGE, BRANCHCHANGE, URLCHANGE = [1 << x for x in range(UpdateProgress._num_op_codes, UpdateProgress._num_op_codes + 4)]
+ _num_op_codes = UpdateProgress._num_op_codes + 4
__slots__ = tuple()
@@ -39,13 +39,13 @@ class RootModule(Submodule):
# repo, binsha, mode=None, path=None, name = None, parent_commit=None, url=None, ref=None)
super(RootModule, self).__init__(
repo,
- binsha = self.NULL_BIN_SHA,
- mode = self.k_default_mode,
- path = '',
- name = self.k_root_name,
- parent_commit = repo.head.commit,
- url = '',
- branch_path = git.Head.to_full_path(self.k_head_default)
+ binsha=self.NULL_BIN_SHA,
+ mode=self.k_default_mode,
+ path='',
+ name=self.k_root_name,
+ parent_commit=repo.head.commit,
+ url='',
+ branch_path=git.Head.to_full_path(self.k_head_default)
)
def _clear_cache(self):
@@ -126,16 +126,16 @@ class RootModule(Submodule):
# fake it into thinking its at the current commit to allow deletion
# of previous module. Trigger the cache to be updated before that
- progress.update(op, i, len_rrsm, prefix+"Removing submodule %r at %s" % (rsm.name, rsm.abspath))
+ progress.update(op, i, len_rrsm, prefix + "Removing submodule %r at %s" % (rsm.name, rsm.abspath))
rsm._parent_commit = repo.head.commit
if not dry_run:
rsm.remove(configuration=False, module=True, force=force_remove)
#END handle dry-run
- if i == len_rrsm-1:
+ if i == len_rrsm - 1:
op |= END
#END handle end
- progress.update(op, i, len_rrsm, prefix+"Done removing submodule %r" % rsm.name)
+ progress.update(op, i, len_rrsm, prefix + "Done removing submodule %r" % rsm.name)
# END for each removed submodule
# HANDLE PATH RENAMES
@@ -150,12 +150,12 @@ class RootModule(Submodule):
#PATH CHANGES
##############
if sm.path != psm.path and psm.module_exists():
- progress.update(BEGIN|PATHCHANGE, i, len_csms, prefix+"Moving repository of submodule %r from %s to %s" % (sm.name, psm.abspath, sm.abspath))
+ progress.update(BEGIN | PATHCHANGE, i, len_csms, prefix + "Moving repository of submodule %r from %s to %s" % (sm.name, psm.abspath, sm.abspath))
# move the module to the new path
if not dry_run:
psm.move(sm.path, module=True, configuration=False)
#END handle dry_run
- progress.update(END|PATHCHANGE, i, len_csms, prefix+"Done moving repository of submodule %r" % sm.name)
+ progress.update(END | PATHCHANGE, i, len_csms, prefix + "Done moving repository of submodule %r" % sm.name)
# END handle path changes
if sm.module_exists():
@@ -171,7 +171,7 @@ class RootModule(Submodule):
# don't do anything if we already have the url we search in place
if len([r for r in rmts if r.url == sm.url]) == 0:
- progress.update(BEGIN|URLCHANGE, i, len_csms, prefix+"Changing url of submodule %r from %s to %s" % (sm.name, psm.url, sm.url))
+ progress.update(BEGIN | URLCHANGE, i, len_csms, prefix + "Changing url of submodule %r from %s to %s" % (sm.name, psm.url, sm.url))
if not dry_run:
assert nn not in [r.name for r in rmts]
@@ -245,7 +245,7 @@ class RootModule(Submodule):
#NOTE: All checkout is performed by the base implementation of update
#END handle dry_run
- progress.update(END|URLCHANGE, i, len_csms, prefix+"Done adjusting url of submodule %r" % (sm.name))
+ progress.update(END | URLCHANGE, i, len_csms, prefix + "Done adjusting url of submodule %r" % (sm.name))
# END skip remote handling if new url already exists in module
# END handle url
@@ -254,7 +254,7 @@ class RootModule(Submodule):
if sm.branch_path != psm.branch_path:
# finally, create a new tracking branch which tracks the
# new remote branch
- progress.update(BEGIN|BRANCHCHANGE, i, len_csms, prefix+"Changing branch of submodule %r from %s to %s" % (sm.name, psm.branch_path, sm.branch_path))
+ progress.update(BEGIN | BRANCHCHANGE, i, len_csms, prefix + "Changing branch of submodule %r from %s to %s" % (sm.name, psm.branch_path, sm.branch_path))
if not dry_run:
smm = sm.module()
smmr = smm.remotes
@@ -283,7 +283,7 @@ class RootModule(Submodule):
#NOTE: All checkout is done in the base implementation of update
#END handle dry_run
- progress.update(END|BRANCHCHANGE, i, len_csms, prefix+"Done changing branch of submodule %r" % sm.name)
+ progress.update(END | BRANCHCHANGE, i, len_csms, prefix + "Done changing branch of submodule %r" % sm.name)
#END handle branch
#END handle
# END for each common submodule
@@ -302,7 +302,7 @@ class RootModule(Submodule):
if recursive:
# the module would exist by now if we are not in dry_run mode
if sm.module_exists():
- type(self)(sm.module()).update( recursive=True, force_remove=force_remove,
+ type(self)(sm.module()).update(recursive=True, force_remove=force_remove,
init=init, to_latest_revision=to_latest_revision,
progress=progress, dry_run=dry_run)
#END handle dry_run
diff --git a/git/objects/submodule/util.py b/git/objects/submodule/util.py
index 47b45109..a66fcddc 100644
--- a/git/objects/submodule/util.py
+++ b/git/objects/submodule/util.py
@@ -4,7 +4,7 @@ from git.config import GitConfigParser
from StringIO import StringIO
import weakref
-__all__ = ( 'sm_section', 'sm_name', 'mkhead', 'unbare_repo', 'find_first_remote_branch',
+__all__ = ('sm_section', 'sm_name', 'mkhead', 'unbare_repo', 'find_first_remote_branch',
'SubmoduleConfigParser')
#{ Utilities
diff --git a/git/objects/tag.py b/git/objects/tag.py
index 3690dc45..7ba8ce29 100644
--- a/git/objects/tag.py
+++ b/git/objects/tag.py
@@ -18,7 +18,7 @@ class TagObject(base.Object):
"""Non-Lightweight tag carrying additional information about an object we are pointing to."""
type = "tag"
- __slots__ = ( "object", "tag", "tagger", "tagged_date", "tagger_tz_offset", "message" )
+ __slots__ = ("object", "tag", "tagger", "tagged_date", "tagger_tz_offset", "message")
def __init__(self, repo, binsha, object=None, tag=None,
tagger=None, tagged_date=None, tagger_tz_offset=None, message=None):
@@ -34,7 +34,7 @@ class TagObject(base.Object):
it into a different format
:param tagged_tz_offset: int_seconds_west_of_utc is the timezone that the
authored_date is in, in a format similar to time.altzone"""
- super(TagObject, self).__init__(repo, binsha )
+ super(TagObject, self).__init__(repo, binsha)
if object is not None:
self.object = object
if tag is not None:
diff --git a/git/objects/tree.py b/git/objects/tree.py
index 4984823e..e4e49d1a 100644
--- a/git/objects/tree.py
+++ b/git/objects/tree.py
@@ -125,13 +125,13 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable):
tree_id = 004
_map_id_to_type = {
- commit_id : Submodule,
- blob_id : Blob,
- symlink_id : Blob
+ commit_id: Submodule,
+ blob_id: Blob,
+ symlink_id: Blob
# tree id added once Tree is defined
}
- def __init__(self, repo, binsha, mode=tree_id<<12, path=None):
+ def __init__(self, repo, binsha, mode=tree_id << 12, path=None):
super(Tree, self).__init__(repo, binsha, mode, path)
@classmethod
@@ -170,13 +170,13 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable):
tree = self
item = self
tokens = file.split('/')
- for i,token in enumerate(tokens):
+ for i, token in enumerate(tokens):
item = tree[token]
if item.type == 'tree':
tree = item
else:
# safety assertion - blobs are at the end of the path
- if i != len(tokens)-1:
+ if i != len(tokens) - 1:
raise KeyError(msg % file)
return item
# END handle item type
@@ -189,18 +189,18 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable):
if info[2] == file: # [2] == name
return self._map_id_to_type[info[1] >> 12](self.repo, info[0], info[1], join_path(self.path, info[2]))
# END for each obj
- raise KeyError( msg % file )
+ raise KeyError(msg % file)
# END handle long paths
@property
def trees(self):
""":return: list(Tree, ...) list of trees directly below this tree"""
- return [ i for i in self if i.type == "tree" ]
+ return [i for i in self if i.type == "tree"]
@property
def blobs(self):
""":return: list(Blob, ...) list of blobs directly below this tree"""
- return [ i for i in self if i.type == "blob" ]
+ return [i for i in self if i.type == "blob"]
@property
def cache(self):
@@ -211,9 +211,9 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable):
See the ``TreeModifier`` for more information on how to alter the cache"""
return TreeModifier(self._cache)
- def traverse( self, predicate = lambda i,d: True,
- prune = lambda i,d: False, depth = -1, branch_first=True,
- visit_once = False, ignore_self=1 ):
+ def traverse(self, predicate=lambda i, d: True,
+ prune=lambda i, d: False, depth=-1, branch_first=True,
+ visit_once=False, ignore_self=1):
"""For documentation, see util.Traversable.traverse
Trees are set to visit_once = False to gain more performance in the traversal"""
return super(Tree, self).traverse(predicate, prune, depth, branch_first, visit_once, ignore_self)
@@ -238,7 +238,7 @@ class Tree(IndexObject, diff.Diffable, util.Traversable, util.Serializable):
return self.__div__(item)
# END index is basestring
- raise TypeError( "Invalid index type: %r" % item )
+ raise TypeError("Invalid index type: %r" % item)
def __contains__(self, item):
if isinstance(item, IndexObject):
diff --git a/git/objects/util.py b/git/objects/util.py
index 9f947fcc..6321399d 100644
--- a/git/objects/util.py
+++ b/git/objects/util.py
@@ -33,7 +33,7 @@ def mode_str_to_int(modestr):
for example."""
mode = 0
for iteration, char in enumerate(reversed(modestr[-6:])):
- mode += int(char) << iteration*3
+ mode += int(char) << iteration * 3
# END for each char
return mode
@@ -67,15 +67,15 @@ def utctz_to_altz(utctz):
returns. Git stores it as UTC timezone which has the opposite sign as well,
which explains the -1 * ( that was made explicit here )
:param utctz: git utc timezone string, i.e. +0200"""
- return -1 * int(float(utctz)/100*3600)
+ return -1 * int(float(utctz) / 100 * 3600)
def altz_to_utctz_str(altz):
"""As above, but inverses the operation, returning a string that can be used
in commit objects"""
- utci = -1 * int((altz / 3600)*100)
+ utci = -1 * int((altz / 3600) * 100)
utcs = str(abs(utci))
- utcs = "0"*(4-len(utcs)) + utcs
+ utcs = "0" * (4 - len(utcs)) + utcs
prefix = (utci < 0 and '-') or '+'
return prefix + utcs
@@ -144,7 +144,7 @@ def parse_date(string_date):
assert splitter > -1
# split date and time
- time_part = string_date[splitter+1:] # skip space
+ time_part = string_date[splitter + 1:] # skip space
date_part = string_date[:splitter]
# parse time
@@ -237,9 +237,9 @@ class Traversable(object):
out.extend(self.traverse(*args, **kwargs))
return out
- def traverse( self, predicate = lambda i,d: True,
- prune = lambda i,d: False, depth = -1, branch_first=True,
- visit_once = True, ignore_self=1, as_edge = False ):
+ def traverse(self, predicate=lambda i, d: True,
+ prune=lambda i, d: False, depth=-1, branch_first=True,
+ visit_once=True, ignore_self=1, as_edge=False):
""":return: iterator yieling of items found when traversing self
:param predicate: f(i,d) returns False if item i at depth d should not be included in the result
@@ -272,17 +272,17 @@ class Traversable(object):
source to destination"""
visited = set()
stack = Deque()
- stack.append( ( 0 ,self, None ) ) # self is always depth level 0
+ stack.append((0, self, None)) # self is always depth level 0
- def addToStack( stack, item, branch_first, depth ):
- lst = self._get_intermediate_items( item )
+ def addToStack(stack, item, branch_first, depth):
+ lst = self._get_intermediate_items(item)
if not lst:
return
if branch_first:
- stack.extendleft( ( depth , i, item ) for i in lst )
+ stack.extendleft((depth, i, item) for i in lst)
else:
- reviter = ( ( depth , lst[i], item ) for i in range( len( lst )-1,-1,-1) )
- stack.extend( reviter )
+ reviter = ((depth, lst[i], item) for i in range(len(lst) - 1, -1, -1))
+ stack.extend(reviter)
# END addToStack local method
while stack:
@@ -294,12 +294,12 @@ class Traversable(object):
if visit_once:
visited.add(item)
- rval = ( as_edge and (src, item) ) or item
- if prune( rval, d ):
+ rval = (as_edge and (src, item)) or item
+ if prune(rval, d):
continue
- skipStartItem = ignore_self and ( item is self )
- if not skipStartItem and predicate( rval, d ):
+ skipStartItem = ignore_self and (item is self)
+ if not skipStartItem and predicate(rval, d):
yield rval
# only continue to next level if this is appropriate !
@@ -307,7 +307,7 @@ class Traversable(object):
if depth > -1 and nd > depth:
continue
- addToStack( stack, item, branch_first, nd )
+ addToStack(stack, item, branch_first, nd)
# END for each item on work stack