Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/virtualenv/config/env_var.py @ 5:9b1c78e6ba9c draft default tip
"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author | shellac |
---|---|
date | Mon, 01 Jun 2020 08:59:25 -0400 |
parents | 79f47841a781 |
children |
comparison
equal
deleted
inserted
replaced
4:79f47841a781 | 5:9b1c78e6ba9c |
---|---|
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",) |