Skip to content

Commit 53b5ed2

Browse files
committed
fixed string formatting in utils
1 parent d051202 commit 53b5ed2

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

docker/utils/utils.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ def convert_volume_binds(binds):
163163
result = []
164164
for k, v in binds.items():
165165
if isinstance(v, dict):
166-
result.append('%s:%s:%s' % (
166+
result.append('{0}:{1}:{2}'.format(
167167
k, v['bind'], 'ro' if v.get('ro', False) else 'rw'
168168
))
169169
else:
170-
result.append('%s:%s:rw' % (k, v))
170+
result.append('{0}:{1}:rw'.format(k, v))
171171
return result
172172

173173

@@ -201,7 +201,8 @@ def parse_host(addr):
201201
addr = addr.replace('http+unix://', 'unix://')
202202

203203
if addr == 'tcp://':
204-
raise errors.DockerException("Invalid bind address format: %s" % addr)
204+
raise errors.DockerException(
205+
"Invalid bind address format: {0}".format(addr))
205206
elif addr.startswith('unix://'):
206207
addr = addr[7:]
207208
elif addr.startswith('tcp://'):
@@ -215,15 +216,15 @@ def parse_host(addr):
215216
else:
216217
if "://" in addr:
217218
raise errors.DockerException(
218-
"Invalid bind address protocol: %s" % addr
219+
"Invalid bind address protocol: {0]".format(addr)
219220
)
220221
proto = "http"
221222

222223
if proto != "http+unix" and ":" in addr:
223224
host_parts = addr.split(':')
224225
if len(host_parts) != 2:
225226
raise errors.DockerException(
226-
"Invalid bind address format: %s" % addr
227+
"Invalid bind address format: {0}".format(addr)
227228
)
228229
if host_parts[0]:
229230
host = host_parts[0]
@@ -236,13 +237,14 @@ def parse_host(addr):
236237
)
237238

238239
elif proto in ("http", "https") and ':' not in addr:
239-
raise errors.DockerException("Bind address needs a port: %s" % addr)
240+
raise errors.DockerException(
241+
"Bind address needs a port: {0}".format(addr))
240242
else:
241243
host = addr
242244

243245
if proto == "http+unix":
244-
return "%s://%s" % (proto, host)
245-
return "%s://%s:%d" % (proto, host, port)
246+
return "{0}://{1}".format(proto, host)
247+
return "{0}://{1}:{2}" % (proto, host, port)
246248

247249

248250
def parse_devices(devices):

0 commit comments

Comments
 (0)