From 26781cb1535dca449bb120606add16fe1af7ce73 Mon Sep 17 00:00:00 2001 From: James Maslek Date: Tue, 17 May 2022 18:50:18 -0400 Subject: [PATCH] Tidy up autoloading in places (#1832) * Only try loading from stocks and crypto contexts * im terrible with git --- openbb_terminal/etf/etf_controller.py | 1 + openbb_terminal/mutual_funds/mutual_fund_controller.py | 1 + openbb_terminal/parent_classes.py | 8 +++++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/openbb_terminal/etf/etf_controller.py b/openbb_terminal/etf/etf_controller.py index 4b065dd2bf4..fd986c3c0d2 100644 --- a/openbb_terminal/etf/etf_controller.py +++ b/openbb_terminal/etf/etf_controller.py @@ -80,6 +80,7 @@ class ETFController(BaseController): self.etf_name = "" self.etf_data = "" self.etf_holdings: List = list() + self.TRY_RELOAD = True if session and obbff.USE_PROMPT_TOOLKIT: choices: dict = {c: {} for c in self.controller_choices} diff --git a/openbb_terminal/mutual_funds/mutual_fund_controller.py b/openbb_terminal/mutual_funds/mutual_fund_controller.py index 49b830cfe01..958cc7bef62 100644 --- a/openbb_terminal/mutual_funds/mutual_fund_controller.py +++ b/openbb_terminal/mutual_funds/mutual_fund_controller.py @@ -76,6 +76,7 @@ class FundController(BaseController): self.data = pd.DataFrame() self.fund_name = "" self.fund_symbol = "" + self.TRY_RELOAD = True if session and obbff.USE_PROMPT_TOOLKIT: choices: dict = {c: {} for c in self.controller_choices} diff --git a/openbb_terminal/parent_classes.py b/openbb_terminal/parent_classes.py index ed2e62403ed..81e735a8066 100644 --- a/openbb_terminal/parent_classes.py +++ b/openbb_terminal/parent_classes.py @@ -76,7 +76,7 @@ class BaseController(metaclass=ABCMeta): SUPPORT_CHOICES: Dict = {} COMMAND_SEPARATOR = "/" KEYS_MENU = "keys" + COMMAND_SEPARATOR - + TRY_RELOAD = False PATH: str = "" FILE_PATH: str = "" @@ -163,7 +163,7 @@ class BaseController(metaclass=ABCMeta): @abstractmethod def print_help(self) -> None: - raise NotImplementedError("Must override print_help") + raise NotImplementedError("Must override print_help.") def contains_keys(self, string_to_check: str) -> bool: if self.KEYS_MENU in string_to_check or self.KEYS_MENU in self.PATH: @@ -462,7 +462,7 @@ class BaseController(metaclass=ABCMeta): console.print(f" Replacing by '{an_input}'.") self.queue.insert(0, an_input) else: - if "load" in self.controller_choices: + if self.TRY_RELOAD: console.print(f"Trying `load {an_input}`") self.queue.insert(0, "load " + an_input) console.print("") @@ -480,6 +480,7 @@ class StockBaseController(BaseController, metaclass=ABCMeta): self.start = "" self.suffix = "" # To hold suffix for Yahoo Finance self.add_info = stocks_helper.additional_info_about_ticker("") + self.TRY_RELOAD = True def call_load(self, other_args: List[str]): """Process load command""" @@ -670,6 +671,7 @@ class CryptoBaseController(BaseController, metaclass=ABCMeta): self.price_str = "" self.resolution = "1D" self.coin = "" + self.TRY_RELOAD = True def call_load(self, other_args): """Process load command"""