summaryrefslogtreecommitdiff
path: root/docker/utils/utils.py
diff options
context:
space:
mode:
authornir0s <nir36g@gmail.com>2015-02-11 22:24:06 +0200
committernir0s <nir36g@gmail.com>2015-02-11 22:24:06 +0200
commit53b5ed2178bec143d3dced71a36cc9112e1149bf (patch)
tree906bebe3e9a881d851e6c6d2d01ffe4350aac20d /docker/utils/utils.py
parentd0512028be0301325a59bc94831743e628e3108e (diff)
downloaddocker-py-53b5ed2178bec143d3dced71a36cc9112e1149bf.tar.gz
fixed string formatting in utils
Diffstat (limited to 'docker/utils/utils.py')
-rw-r--r--docker/utils/utils.py18
1 files changed, 10 insertions, 8 deletions
diff --git a/docker/utils/utils.py b/docker/utils/utils.py
index fdaf667..1a41571 100644
--- a/docker/utils/utils.py
+++ b/docker/utils/utils.py
@@ -163,11 +163,11 @@ def convert_volume_binds(binds):
result = []
for k, v in binds.items():
if isinstance(v, dict):
- result.append('%s:%s:%s' % (
+ result.append('{0}:{1}:{2}'.format(
k, v['bind'], 'ro' if v.get('ro', False) else 'rw'
))
else:
- result.append('%s:%s:rw' % (k, v))
+ result.append('{0}:{1}:rw'.format(k, v))
return result
@@ -201,7 +201,8 @@ def parse_host(addr):
addr = addr.replace('http+unix://', 'unix://')
if addr == 'tcp://':
- raise errors.DockerException("Invalid bind address format: %s" % addr)
+ raise errors.DockerException(
+ "Invalid bind address format: {0}".format(addr))
elif addr.startswith('unix://'):
addr = addr[7:]
elif addr.startswith('tcp://'):
@@ -215,7 +216,7 @@ def parse_host(addr):
else:
if "://" in addr:
raise errors.DockerException(
- "Invalid bind address protocol: %s" % addr
+ "Invalid bind address protocol: {0]".format(addr)
)
proto = "http"
@@ -223,7 +224,7 @@ def parse_host(addr):
host_parts = addr.split(':')
if len(host_parts) != 2:
raise errors.DockerException(
- "Invalid bind address format: %s" % addr
+ "Invalid bind address format: {0}".format(addr)
)
if host_parts[0]:
host = host_parts[0]
@@ -236,13 +237,14 @@ def parse_host(addr):
)
elif proto in ("http", "https") and ':' not in addr:
- raise errors.DockerException("Bind address needs a port: %s" % addr)
+ raise errors.DockerException(
+ "Bind address needs a port: {0}".format(addr))
else:
host = addr
if proto == "http+unix":
- return "%s://%s" % (proto, host)
- return "%s://%s:%d" % (proto, host, port)
+ return "{0}://{1}".format(proto, host)
+ return "{0}://{1}:{2}" % (proto, host, port)
def parse_devices(devices):