From 7d2d7a4db8b81aa166d3f74924ab01c48c9f5dd8 Mon Sep 17 00:00:00 2001 From: clothespin Date: Tue, 16 Mar 2021 21:35:21 -0700 Subject: [PATCH] rework feature_flags.py to supply defaults to os.getenv() --- gamestonk_terminal/feature_flags.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/gamestonk_terminal/feature_flags.py b/gamestonk_terminal/feature_flags.py index 6aafa2a0ffb..c96db4a1e7c 100755 --- a/gamestonk_terminal/feature_flags.py +++ b/gamestonk_terminal/feature_flags.py @@ -1,16 +1,23 @@ import os -USE_COLOR = os.getenv("GTFF_USE_COLOR").lower() not in ["false", "0"] or True -USE_FLAIR = os.getenv("GTFF_USE_FLAIR") or "stars" -USE_ION = os.getenv("GTFF_USE_ION").lower() not in ["false", "0"] or True -USE_PROMPT_TOOLKIT = ( - os.getenv("GTFF_USE_PROMPT_TOOLKIT").lower() not in ["false", "0"] or False -) +# env vars are strings not booleans +# check for "false" or "0" +# any other value is true (including empty string) + +USE_COLOR = os.getenv("GTFF_USE_COLOR", "true").lower() not in ["false", "0"] +USE_FLAIR = os.getenv("GTFF_USE_FLAIR", "stars") +USE_ION = os.getenv("GTFF_USE_ION", "true").lower() not in ["false", "0"] +USE_PROMPT_TOOLKIT = os.getenv("GTFF_USE_PROMPT_TOOLKIT", "false").lower() not in [ + "false", + "0", +] + # Enable Prediction features -ENABLE_PREDICT = os.getenv("GTFF_ENABLE_PREDICT").lower() not in ["false", "0"] or False +ENABLE_PREDICT = os.getenv("GTFF_ENABLE_PREDICT", "false").lower() not in ["false", "0"] # Enable plot autoscaling -USE_PLOT_AUTOSCALING = ( - os.getenv("GTFF_USE_PLOT_AUTOSCALING").lower() not in ["false", "0"] or False -) +USE_PLOT_AUTOSCALING = os.getenv("GTFF_USE_PLOT_AUTOSCALING", "false").lower() not in [ + "false", + "0", +]