summaryrefslogtreecommitdiff
path: root/git/objects/submodule/util.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2014-11-17 10:14:43 +0100
committerSebastian Thiel <byronimo@gmail.com>2014-11-17 10:14:43 +0100
commite4d8fb73daa82420bdc69c37f0d58f7cb4cd505a (patch)
tree38e1241fd6d756f783b6b56dc6628ac3ca41ed4f /git/objects/submodule/util.py
parent7aba59a2609ec768d5d495dafd23a4bce8179741 (diff)
parentc8e70749887370a99adeda972cc3503397b5f9a7 (diff)
downloadgitpython-e4d8fb73daa82420bdc69c37f0d58f7cb4cd505a.tar.gz
Merge pull request #204 from hashar/pep8-linting
Pep8 linting
Diffstat (limited to 'git/objects/submodule/util.py')
-rw-r--r--git/objects/submodule/util.py33
1 files changed, 20 insertions, 13 deletions
diff --git a/git/objects/submodule/util.py b/git/objects/submodule/util.py
index 492d9dbe..bbdf5e1e 100644
--- a/git/objects/submodule/util.py
+++ b/git/objects/submodule/util.py
@@ -4,27 +4,32 @@ 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
+
def sm_section(name):
""":return: section title used in .gitmodules configuration file"""
return 'submodule "%s"' % name
+
def sm_name(section):
""":return: name of the submodule as parsed from the section name"""
section = section.strip()
return section[11:-1]
-
+
+
def mkhead(repo, path):
""":return: New branch/head instance"""
return git.Head(repo, git.Head.to_full_path(path))
-
+
+
def unbare_repo(func):
- """Methods with this decorator raise InvalidGitRepositoryError if they
+ """Methods with this decorator raise InvalidGitRepositoryError if they
encounter a bare repository"""
+
def wrapper(self, *args, **kwargs):
if self.repo.bare:
raise InvalidGitRepositoryError("Method '%s' cannot operate on bare repositories" % func.__name__)
@@ -33,7 +38,8 @@ def unbare_repo(func):
# END wrapper
wrapper.__name__ = func.__name__
return wrapper
-
+
+
def find_first_remote_branch(remotes, branch_name):
"""Find the remote branch matching the name of the given branch or raise InvalidGitRepositoryError"""
for remote in remotes:
@@ -44,31 +50,32 @@ def find_first_remote_branch(remotes, branch_name):
# END exception handling
#END for remote
raise InvalidGitRepositoryError("Didn't find remote branch %r in any of the given remotes", branch_name)
-
+
#} END utilities
#{ Classes
class SubmoduleConfigParser(GitConfigParser):
+
"""
Catches calls to _write, and updates the .gitmodules blob in the index
- with the new data, if we have written into a stream. Otherwise it will
+ with the new data, if we have written into a stream. Otherwise it will
add the local file to the index to make it correspond with the working tree.
Additionally, the cache must be cleared
-
+
Please note that no mutating method will work in bare mode
"""
-
+
def __init__(self, *args, **kwargs):
self._smref = None
self._index = None
self._auto_write = True
super(SubmoduleConfigParser, self).__init__(*args, **kwargs)
-
+
#{ Interface
def set_submodule(self, submodule):
- """Set this instance's submodule. It must be called before
+ """Set this instance's submodule. It must be called before
the first write operation begins"""
self._smref = weakref.ref(submodule)
@@ -77,7 +84,7 @@ class SubmoduleConfigParser(GitConfigParser):
assert self._smref is not None
# should always have a file here
assert not isinstance(self._file_or_files, StringIO)
-
+
sm = self._smref()
if sm is not None:
index = self._index
@@ -89,7 +96,7 @@ class SubmoduleConfigParser(GitConfigParser):
# END handle weakref
#} END interface
-
+
#{ Overridden Methods
def write(self):
rval = super(SubmoduleConfigParser, self).write()