comparison planemo/lib/python3.7/site-packages/virtualenv/config/env_var.py @ 1:56ad4e20f292 draft

"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
author guerler
date Fri, 31 Jul 2020 00:32:28 -0400
parents
children
comparison
equal deleted inserted replaced
0:d30785e31577 1:56ad4e20f292
1 from __future__ import absolute_import, unicode_literals
2
3 import os
4
5 from virtualenv.util.six import ensure_str, ensure_text
6
7 from .convert import convert
8
9
10 def get_env_var(key, as_type):
11 """Get the environment variable option.
12
13 :param key: the config key requested
14 :param as_type: the type we would like to convert it to
15 :return:
16 """
17 environ_key = ensure_str("VIRTUALENV_{}".format(key.upper()))
18 if os.environ.get(environ_key):
19 value = os.environ[environ_key]
20 # noinspection PyBroadException
21 try:
22 source = "env var {}".format(ensure_text(environ_key))
23 as_type = convert(value, as_type, source)
24 return as_type, source
25 except Exception: # note the converter already logs a warning when failures happen
26 pass
27
28
29 __all__ = ("get_env_var",)