Skip to content

Commit d75a789

Browse files
committed
Be more inclusive on truthy values for env vars
1 parent c008667 commit d75a789

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

stagpy/__init__.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
documentation at
55
http://stagpy.readthedocs.io/en/stable/
66
7-
If the environment variable STAGPY_ISOLATED is set to 'True', StagPy does not
8-
attempt to read any configuration file (including mplstyle).
7+
If the environment variable STAGPY_ISOLATED is set to a truthy value, StagPy
8+
does not attempt to read any configuration file (including mplstyle).
99
1010
When using the CLI interface, if the environment variable STAGPY_DEBUG is set
11-
to 'True', warnings are issued normally and StagpyError are raised. Otherwise,
12-
warnings are ignored and only a short form of encountered StagpyErrors is
13-
printed.
11+
to a truthy value, warnings are issued normally and StagpyError are raised.
12+
Otherwise, warnings are ignored and only a short form of encountered
13+
StagpyErrors is printed.
14+
15+
Truthy values for environment variables are 'true', 't', 'yes', 'y', 'on', '1',
16+
and uppercase versions of those.
1417
"""
1518

1619
import importlib
@@ -29,7 +32,8 @@
2932

3033
def _env(var):
3134
"""Return whether var is set to True."""
32-
return os.getenv(var) == 'True'
35+
val = os.getenv(var, default='').lower()
36+
return val in ('true', 't', 'yes', 'y', 'on', '1')
3337

3438

3539
DEBUG = _env('STAGPY_DEBUG')

0 commit comments

Comments
 (0)