aboutsummaryrefslogtreecommitdiffstats
path: root/django/cms/envbool.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/cms/envbool.py')
-rw-r--r--[-rwxr-xr-x]django/cms/envbool.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/django/cms/envbool.py b/django/cms/envbool.py
index 72994d8..df9dd29 100755..100644
--- a/django/cms/envbool.py
+++ b/django/cms/envbool.py
@@ -1,4 +1,4 @@
-# ============LICENSE_START==========================================
+# ============LICENSE_START==========================================
# org.onap.vvp/cms
# ===================================================================
# Copyright © 2017 AT&T Intellectual Property. All rights reserved.
@@ -37,24 +37,28 @@
# ECOMP is a trademark and service mark of AT&T Intellectual Property.
import os
+
def envbool(key, default=False, unknown=True):
"""Return a boolean value based on that of an environment variable.
- Environment variables have no native boolean type. They are always strings, and may be empty or
- unset (which differs from empty.) Furthermore, notions of what is "truthy" in shell script
- differ from that of python.
+ Environment variables have no native boolean type. They are always strings,
+ and may be empty or unset (which differs from empty.) Furthermore,
+ notions of what is "truthy" in shell script differ from that of python.
- This function converts environment variables to python boolean True or False in
- case-insensitive, expected ways to avoid pitfalls:
+ This function converts environment variables to python
+ boolean True or False in case-insensitive,
+ expected ways to avoid pitfalls:
"True", "true", and "1" become True
"False", "false", and "0" become False
- unset or empty becomes False by default (toggle with 'default' parameter.)
- any other value becomes True by default (toggle with 'unknown' parameter.)
+ unset or empty becomes False by default
+ (toggle with 'default' parameter.)
+ any other value becomes True by default
+ (toggle with 'unknown' parameter.)
"""
return {
- 'true': True, '1': True, # 't': True,
- 'false': False, '0': False, # 'f': False.
+ 'true': True, '1': True, # 't': True,
+ 'false': False, '0': False, # 'f': False.
'': default,
- }.get(os.getenv(key, '').lower(), unknown)
+ }.get(os.getenv(key, '').lower(), unknown)