Skip to content

Commit 5f552fd

Browse files
committed
Merge pull request #486 from nir0s/fix-old-style-string-formatting
Fix old style string formatting
2 parents c5f4c7e + dd1a6fc commit 5f552fd

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

docker/errors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ def __str__(self):
3030
message = super(APIError, self).__str__()
3131

3232
if self.is_client_error():
33-
message = '%s Client Error: %s' % (
33+
message = '{0} Client Error: {1}'.format(
3434
self.response.status_code, self.response.reason)
3535

3636
elif self.is_server_error():
37-
message = '%s Server Error: %s' % (
37+
message = '{0} Server Error: {1}'.format(
3838
self.response.status_code, self.response.reason)
3939

4040
if self.explanation:
41-
message = '%s ("%s")' % (message, self.explanation)
41+
message = '{0} ("{1}")'.format(message, self.explanation)
4242

4343
return message
4444

docker/utils/utils.py

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

175175

@@ -203,7 +203,8 @@ def parse_host(addr):
203203
addr = addr.replace('http+unix://', 'unix://')
204204

205205
if addr == 'tcp://':
206-
raise errors.DockerException("Invalid bind address format: %s" % addr)
206+
raise errors.DockerException(
207+
"Invalid bind address format: {0}".format(addr))
207208
elif addr.startswith('unix://'):
208209
addr = addr[7:]
209210
elif addr.startswith('tcp://'):
@@ -217,15 +218,15 @@ def parse_host(addr):
217218
else:
218219
if "://" in addr:
219220
raise errors.DockerException(
220-
"Invalid bind address protocol: %s" % addr
221+
"Invalid bind address protocol: {0}".format(addr)
221222
)
222223
proto = "http"
223224

224225
if proto != "http+unix" and ":" in addr:
225226
host_parts = addr.split(':')
226227
if len(host_parts) != 2:
227228
raise errors.DockerException(
228-
"Invalid bind address format: %s" % addr
229+
"Invalid bind address format: {0}".format(addr)
229230
)
230231
if host_parts[0]:
231232
host = host_parts[0]
@@ -238,13 +239,14 @@ def parse_host(addr):
238239
)
239240

240241
elif proto in ("http", "https") and ':' not in addr:
241-
raise errors.DockerException("Bind address needs a port: %s" % addr)
242+
raise errors.DockerException(
243+
"Bind address needs a port: {0}".format(addr))
242244
else:
243245
host = addr
244246

245247
if proto == "http+unix":
246-
return "%s://%s" % (proto, host)
247-
return "%s://%s:%d" % (proto, host, port)
248+
return "{0}://{1}".format(proto, host)
249+
return "{0}://{1}:{2}".format(proto, host, port)
248250

249251

250252
def parse_devices(devices):

0 commit comments

Comments
 (0)