浏览代码

Pass the interpolation value to python-dotenv

Signed-off-by: Ulysses Souza <[email protected]>
Ulysses Souza 5 年之前
父节点
当前提交
edf27e486a
共有 2 个文件被更改,包括 6 次插入3 次删除
  1. 4 2
      compose/config/environment.py
  2. 2 1
      requirements.txt

+ 4 - 2
compose/config/environment.py

@@ -39,8 +39,10 @@ def env_vars_from_file(filename, interpolate=True):
     elif not os.path.isfile(filename):
         raise EnvFileNotFound("{} is not a file.".format(filename))
 
-    # TODO: now we should do something with interpolate here, but what?
-    return dotenv.dotenv_values(dotenv_path=filename, encoding='utf-8-sig')
+    env = dotenv.dotenv_values(dotenv_path=filename, encoding='utf-8-sig', interpolate=interpolate)
+    for k, v in env.items():
+        env[k] = v if interpolate else v.replace('$', '$$')
+    return env
 
 
 class Environment(dict):

+ 2 - 1
requirements.txt

@@ -10,6 +10,7 @@ dockerpty==0.4.1
 docopt==0.6.2
 enum34==1.1.6; python_version < '3.4'
 functools32==3.2.3.post2; python_version < '3.2'
+git+git://github.com/ulyssessouza/python-dotenv.git@no-interpolate#egg=python-dotenv
 idna==2.8
 ipaddress==1.0.23
 jsonschema==3.2.0
@@ -17,7 +18,7 @@ paramiko==2.7.1
 pypiwin32==219; sys_platform == 'win32' and python_version < '3.6'
 pypiwin32==223; sys_platform == 'win32' and python_version >= '3.6'
 PySocks==1.7.1
-python-dotenv==0.10.5
+#python-dotenv==0.10.5
 PyYAML==5.3
 requests==2.22.0
 six==1.12.0