dulwich-users team mailing list archive
-
dulwich-users team
-
Mailing list archive
-
Message #00391
[PATCH 3/7] client: Standardize on single quotes.
From: Dave Borowitz <dborowitz@xxxxxxxxxx>
Change-Id: I5566af67336445654d661ff13c957d883c563011
---
dulwich/client.py | 44 +++++++++++++++++++++---------------------
dulwich/tests/test_client.py | 17 +++++++--------
2 files changed, 30 insertions(+), 31 deletions(-)
diff --git a/dulwich/client.py b/dulwich/client.py
index 655d9e5..0dcefe4 100644
--- a/dulwich/client.py
+++ b/dulwich/client.py
@@ -44,8 +44,8 @@ def _fileno_can_read(fileno):
"""Check if a file descriptor is readable."""
return len(select.select([fileno], [], [], 0)[0]) > 0
-COMMON_CAPABILITIES = ["ofs-delta"]
-FETCH_CAPABILITIES = ["multi_ack", "side-band-64k"] + COMMON_CAPABILITIES
+COMMON_CAPABILITIES = ['ofs-delta']
+FETCH_CAPABILITIES = ['multi_ack', 'side-band-64k'] + COMMON_CAPABILITIES
SEND_CAPABILITIES = ['report-status'] + COMMON_CAPABILITIES
# TODO(durin42): this doesn't correctly degrade if the server doesn't
@@ -67,7 +67,7 @@ class GitClient(object):
self._fetch_capabilities = list(FETCH_CAPABILITIES)
self._send_capabilities = list(SEND_CAPABILITIES)
if thin_packs:
- self._fetch_capabilities.append("thin-pack")
+ self._fetch_capabilities.append('thin-pack')
def _connect(self, cmd, path):
"""Create a connection to the server.
@@ -88,7 +88,7 @@ class GitClient(object):
refs = {}
# Receive refs from server
for pkt in proto.read_pkt_seq():
- (sha, ref) = pkt.rstrip("\n").split(" ", 1)
+ (sha, ref) = pkt.rstrip('\n').split(' ', 1)
if server_capabilities is None:
(ref, server_capabilities) = extract_capabilities(ref)
refs[ref] = sha
@@ -161,11 +161,11 @@ class GitClient(object):
new_sha1 = new_refs.get(refname, ZERO_SHA)
if old_sha1 != new_sha1:
if sent_capabilities:
- proto.write_pkt_line("%s %s %s" % (old_sha1, new_sha1,
+ proto.write_pkt_line('%s %s %s' % (old_sha1, new_sha1,
refname))
else:
proto.write_pkt_line(
- "%s %s %s\0%s" % (old_sha1, new_sha1, refname,
+ '%s %s %s\0%s' % (old_sha1, new_sha1, refname,
' '.join(self._send_capabilities)))
sent_capabilities = True
if new_sha1 not in have and new_sha1 != ZERO_SHA:
@@ -220,28 +220,28 @@ class GitClient(object):
proto.write_pkt_line(None)
return refs
assert isinstance(wants, list) and type(wants[0]) == str
- proto.write_pkt_line("want %s %s\n" % (
+ proto.write_pkt_line('want %s %s\n' % (
wants[0], ' '.join(self._fetch_capabilities)))
for want in wants[1:]:
- proto.write_pkt_line("want %s\n" % want)
+ proto.write_pkt_line('want %s\n' % want)
proto.write_pkt_line(None)
have = graph_walker.next()
while have:
- proto.write_pkt_line("have %s\n" % have)
+ proto.write_pkt_line('have %s\n' % have)
if can_read():
pkt = proto.read_pkt_line()
- parts = pkt.rstrip("\n").split(" ")
- if parts[0] == "ACK":
+ parts = pkt.rstrip('\n').split(' ')
+ if parts[0] == 'ACK':
graph_walker.ack(parts[1])
- assert parts[2] == "continue"
+ assert parts[2] == 'continue'
have = graph_walker.next()
- proto.write_pkt_line("done\n")
+ proto.write_pkt_line('done\n')
pkt = proto.read_pkt_line()
while pkt:
- parts = pkt.rstrip("\n").split(" ")
- if parts[0] == "ACK":
- graph_walker.ack(pkt.split(" ")[1])
- if len(parts) < 3 or parts[2] != "continue":
+ parts = pkt.rstrip('\n').split(' ')
+ if parts[0] == 'ACK':
+ graph_walker.ack(pkt.split(' ')[1])
+ if len(parts) < 3 or parts[2] != 'continue':
break
pkt = proto.read_pkt_line()
# TODO(durin42): this is broken if the server didn't support the
@@ -255,7 +255,7 @@ class GitClient(object):
if progress is not None:
progress(pkt)
else:
- raise AssertionError("Invalid sideband channel %d" % channel)
+ raise AssertionError('Invalid sideband channel %d' % channel)
return refs
@@ -322,7 +322,7 @@ class SSHVendor(object):
if port is not None:
args.extend(['-p', str(port)])
if username is not None:
- host = "%s@%s" % (username, host)
+ host = '%s@%s' % (username, host)
args.append(host)
proc = subprocess.Popen(args + command,
stdin=subprocess.PIPE,
@@ -359,10 +359,10 @@ def get_transport_and_path(uri):
:return: Tuple with client instance and relative path.
"""
from dulwich.client import TCPGitClient, SSHGitClient, SubprocessGitClient
- for handler, transport in (("git://", TCPGitClient), ("git+ssh://", SSHGitClient)):
+ for handler, transport in (('git://', TCPGitClient), ('git+ssh://', SSHGitClient)):
if uri.startswith(handler):
- host, path = uri[len(handler):].split("/", 1)
- return transport(host), "/"+path
+ host, path = uri[len(handler):].split('/', 1)
+ return transport(host), '/'+path
# FIXME: Parse rsync-like git URLs (user@host:/path), bug 568493
# if its not git or git+ssh, try a local url..
return SubprocessGitClient(), uri
diff --git a/dulwich/tests/test_client.py b/dulwich/tests/test_client.py
index 976b9df..9390be1 100644
--- a/dulwich/tests/test_client.py
+++ b/dulwich/tests/test_client.py
@@ -60,23 +60,22 @@ class GitClientTests(TestCase):
def test_fetch_pack_none(self):
self.rin.write(
- "008855dcc6bf963f922e1ed5c4bbaaefcfacef57b1d7 HEAD.multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag\n"
- "0000")
+ '008855dcc6bf963f922e1ed5c4bbaaefcfacef57b1d7 HEAD.multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag\n'
+ '0000')
self.rin.seek(0)
- self.client.fetch_pack("bla", lambda heads: [], None, None, None)
- self.assertEquals(self.rout.getvalue(), "0000")
+ self.client.fetch_pack('bla', lambda heads: [], None, None, None)
+ self.assertEquals(self.rout.getvalue(), '0000')
class SSHGitClientTests(TestCase):
def setUp(self):
super(SSHGitClientTests, self).setUp()
- self.client = SSHGitClient("git.samba.org")
+ self.client = SSHGitClient('git.samba.org')
def test_default_command(self):
- self.assertEquals("git-upload-pack", self.client._get_cmd_path("upload-pack"))
+ self.assertEquals('git-upload-pack', self.client._get_cmd_path('upload-pack'))
def test_alternative_command_path(self):
- self.client.alternative_paths["upload-pack"] = "/usr/lib/git/git-upload-pack"
- self.assertEquals("/usr/lib/git/git-upload-pack", self.client._get_cmd_path("upload-pack"))
-
+ self.client.alternative_paths['upload-pack'] = '/usr/lib/git/git-upload-pack'
+ self.assertEquals('/usr/lib/git/git-upload-pack', self.client._get_cmd_path('upload-pack'))
--
1.7.3.2.168.gd6b63
Follow ups
References