mirror of https://github.com/docker/compose.git
Style and language fixes
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
5232100331
commit
0323920957
|
@ -5,7 +5,7 @@ import codecs
|
||||||
import contextlib
|
import contextlib
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import string
|
import re
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
@ -15,8 +15,6 @@ from .errors import EnvFileNotFound
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
whitespace = set(string.whitespace)
|
|
||||||
|
|
||||||
|
|
||||||
def split_env(env):
|
def split_env(env):
|
||||||
if isinstance(env, six.binary_type):
|
if isinstance(env, six.binary_type):
|
||||||
|
@ -26,10 +24,9 @@ def split_env(env):
|
||||||
key, value = env.split('=', 1)
|
key, value = env.split('=', 1)
|
||||||
else:
|
else:
|
||||||
key = env
|
key = env
|
||||||
for k in key:
|
if re.search(r'\s', key):
|
||||||
if k in whitespace:
|
|
||||||
raise ConfigurationError(
|
raise ConfigurationError(
|
||||||
"environment variable name '%s' may not contains white spaces." % key
|
"environment variable name '{}' may not contains whitespace.".format(key)
|
||||||
)
|
)
|
||||||
return key, value
|
return key, value
|
||||||
|
|
||||||
|
@ -39,9 +36,9 @@ def env_vars_from_file(filename):
|
||||||
Read in a line delimited file of environment variables.
|
Read in a line delimited file of environment variables.
|
||||||
"""
|
"""
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(filename):
|
||||||
raise EnvFileNotFound("Couldn't find env file: %s" % filename)
|
raise EnvFileNotFound("Couldn't find env file: {}".format(filename))
|
||||||
elif not os.path.isfile(filename):
|
elif not os.path.isfile(filename):
|
||||||
raise EnvFileNotFound("%s is not a file." % (filename))
|
raise EnvFileNotFound("{} is not a file.".format(filename))
|
||||||
env = {}
|
env = {}
|
||||||
with contextlib.closing(codecs.open(filename, 'r', 'utf-8-sig')) as fileobj:
|
with contextlib.closing(codecs.open(filename, 'r', 'utf-8-sig')) as fileobj:
|
||||||
for line in fileobj:
|
for line in fileobj:
|
||||||
|
|
Loading…
Reference in New Issue