From 819827a42ddb364f98c3a1a7eae2536dc54bc4cc Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Wed, 12 Feb 2020 15:20:19 +0900 Subject: Fix blank line issues reported by flake8 - E301 expected 1 blank line - E302 expected 2 blank lines - E303 too many blank lines - E305 expected 2 blank lines after class or function definition - E306 expected 1 blank line before a nested definition Fixed automatically with autopep8: git ls-files | grep py$ | xargs autopep8 --in-place \ --select E301,E302,E303,E305,E306 Manually fix issues in project.py caused by misuse of block comments. Change-Id: Iee840fcaff48aae504ddac9c3e76d2acd484f6a9 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254599 Reviewed-by: Mike Frysinger Tested-by: David Pursehouse --- git_config.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'git_config.py') diff --git a/git_config.py b/git_config.py index 13fbda24..5fb61d21 100644 --- a/git_config.py +++ b/git_config.py @@ -59,18 +59,23 @@ ID_RE = re.compile(r'^[0-9a-f]{40}$') REVIEW_CACHE = dict() + def IsChange(rev): return rev.startswith(R_CHANGES) + def IsId(rev): return ID_RE.match(rev) + def IsTag(rev): return rev.startswith(R_TAGS) + def IsImmutable(rev): return IsChange(rev) or IsId(rev) or IsTag(rev) + def _key(name): parts = name.split('.') if len(parts) < 2: @@ -79,6 +84,7 @@ def _key(name): parts[-1] = parts[-1].lower() return '.'.join(parts) + class GitConfig(object): _ForUser = None @@ -392,6 +398,7 @@ _master_keys = set() _ssh_master = True _master_keys_lock = None + def init_ssh(): """Should be called once at the start of repo to init ssh master handling. @@ -401,6 +408,7 @@ def init_ssh(): assert _master_keys_lock is None, "Should only call init_ssh once" _master_keys_lock = _threading.Lock() + def _open_ssh(host, port=None): global _ssh_master @@ -479,6 +487,7 @@ def _open_ssh(host, port=None): finally: _master_keys_lock.release() + def close_ssh(): global _master_keys_lock @@ -503,15 +512,18 @@ def close_ssh(): # We're done with the lock, so we can delete it. _master_keys_lock = None + URI_SCP = re.compile(r'^([^@:]*@?[^:/]{1,}):') URI_ALL = re.compile(r'^([a-z][a-z+-]*)://([^@/]*@?[^/]*)/') + def GetSchemeFromUrl(url): m = URI_ALL.match(url) if m: return m.group(1) return None + @contextlib.contextmanager def GetUrlCookieFile(url, quiet): if url.startswith('persistent-'): @@ -552,6 +564,7 @@ def GetUrlCookieFile(url, quiet): cookiefile = os.path.expanduser(cookiefile) yield cookiefile, None + def _preconnect(url): m = URI_ALL.match(url) if m: @@ -572,9 +585,11 @@ def _preconnect(url): return False + class Remote(object): """Configuration options related to a remote. """ + def __init__(self, config, name): self._config = config self.name = name @@ -735,6 +750,7 @@ class Remote(object): class Branch(object): """Configuration options related to a single branch. """ + def __init__(self, config, name): self._config = config self.name = name -- cgit v1.2.3-54-g00ecf