From 9ea022ab0d62b4ba111e4bee8a5606b3b61971dd Mon Sep 17 00:00:00 2001 From: DidierRLopes Date: Thu, 4 Nov 2021 13:56:26 +0000 Subject: [PATCH] Miscellaneous improvements (#910) * stocks/ba * stocks/disc * stocks/dps * Improve load and candle relation * refactor trendline file * change --plotly to --it * Miscellaneous things --- gamestonk_terminal/feature_flags.py | 7 ++- .../reports/reports_controller.py | 50 +++++++++++++------ 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/gamestonk_terminal/feature_flags.py b/gamestonk_terminal/feature_flags.py index b3af6bbbdb5..fd806967a23 100644 --- a/gamestonk_terminal/feature_flags.py +++ b/gamestonk_terminal/feature_flags.py @@ -20,10 +20,10 @@ USE_COLOR = strtobool(os.getenv("GTFF_USE_COLOR", "True")) USE_FLAIR = os.getenv("GTFF_USE_FLAIR") or "stars" # Enable interactive matplotlib mode -USE_ION = strtobool(os.getenv("GTFF_USE_ION", "False")) +USE_ION = strtobool(os.getenv("GTFF_USE_ION", "True")) # Enable Prompt Toolkit -USE_PROMPT_TOOLKIT = strtobool(os.getenv("GTFF_USE_PROMPT_TOOLKIT", "False")) +USE_PROMPT_TOOLKIT = strtobool(os.getenv("GTFF_USE_PROMPT_TOOLKIT", "True")) # Enable Prediction features ENABLE_PREDICT = strtobool(os.getenv("GTFF_ENABLE_PREDICT", "True")) @@ -36,3 +36,6 @@ ENABLE_THOUGHTS_DAY = strtobool(os.getenv("GTFF_ENABLE_THOUGHTS_DAY", "False")) # Quick exit for testing ENABLE_QUICK_EXIT = strtobool(os.getenv("GTFF_ENABLE_QUICK_EXIT", "False")) + +# Open report as HTML, otherwise notebook +OPEN_REPORT_AS_HTML = strtobool(os.getenv("GTFF_OPEN_REPORT_AS_HTML", "True")) diff --git a/gamestonk_terminal/reports/reports_controller.py b/gamestonk_terminal/reports/reports_controller.py index 15de7c6b201..eead6ff6827 100644 --- a/gamestonk_terminal/reports/reports_controller.py +++ b/gamestonk_terminal/reports/reports_controller.py @@ -16,6 +16,11 @@ from gamestonk_terminal import feature_flags as gtff from gamestonk_terminal.menu import session from gamestonk_terminal.helper_funcs import get_flair, system_clear from gamestonk_terminal import config_terminal +from gamestonk_terminal.helper_funcs import ( + MENU_GO_BACK, + MENU_QUIT, + MENU_RESET, +) class ReportController: @@ -27,6 +32,7 @@ class ReportController: "help", "q", "quit", + "reset", ] reports_folder = os.path.dirname(os.path.abspath(__file__)) @@ -96,6 +102,7 @@ What do you want to do? ?/help show this menu again q quit this menu, and shows back to main menu quit quit to abandon the program + reset reset terminal and reload configs Select one of the following reports: {self.reports_opts}""" @@ -139,12 +146,19 @@ Select one of the following reports: # Go back to menu above if known_args.cmd == "q": proc.kill() - return False + print("") + return MENU_GO_BACK # Quit terminal if known_args.cmd == "quit": proc.kill() - return True + print("") + return MENU_QUIT + + # Reset menu + if known_args.cmd == "reset": + print("") + return MENU_RESET if known_args.cmd: if known_args.cmd in list(self.d_id_to_report_name.keys()): @@ -191,13 +205,23 @@ Select one of the following reports: parameters=d_report_params, ) - webbrowser.open( - os.path.join( - f"http://localhost:{config_terminal.PAPERMILL_NOTEBOOK_REPORT_PORT}", - "notebooks", - notebook_output + ".ipynb", + if gtff.OPEN_REPORT_AS_HTML: + webbrowser.open( + os.path.join( + f"http://localhost:{config_terminal.PAPERMILL_NOTEBOOK_REPORT_PORT}", + "view", + notebook_output + ".html", + ) + ) + + else: + webbrowser.open( + os.path.join( + f"http://localhost:{config_terminal.PAPERMILL_NOTEBOOK_REPORT_PORT}", + "notebooks", + notebook_output + ".ipynb", + ) ) - ) print("") print( @@ -242,12 +266,10 @@ def menu(): try: process_input = report_controller.switch(an_input, proc) + + if process_input is not None: + return process_input + except SystemExit: print("The command selected doesn't exist\n") continue - - if process_input is False: - return False - - if process_input is True: - return True