From 5577d25d85cc8df99bdc72a8df2caf2c6b2fd325 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Thu, 26 Jan 2023 17:23:14 +0000 Subject: [PATCH] implementing chavi suggestions --- openbb_terminal/account/account_controller.py | 114 +++++++++--------- openbb_terminal/miscellaneous/i18n/en.yml | 5 +- openbb_terminal/session/local_model.py | 1 - openbb_terminal/session/user.py | 11 +- 4 files changed, 66 insertions(+), 65 deletions(-) diff --git a/openbb_terminal/account/account_controller.py b/openbb_terminal/account/account_controller.py index 4e59b62c0b6..07c8e2433c8 100644 --- a/openbb_terminal/account/account_controller.py +++ b/openbb_terminal/account/account_controller.py @@ -12,8 +12,9 @@ from openbb_terminal.core.config.paths import USER_ROUTINES_DIRECTORY from openbb_terminal import feature_flags as obbff from openbb_terminal.menu import session from openbb_terminal.session.user import User -from openbb_terminal.session import hub_model as Hub -from openbb_terminal.session import local_model as Local + +# from openbb_terminal.session import hub_model as Hub +# from openbb_terminal.session import local_model as Local logger = logging.getLogger(__name__) @@ -23,9 +24,10 @@ class AccountController(BaseController): CHOICES_COMMANDS = [ "sync", - "force", - "upload", - "download", + "pull", + "defaults", + # "upload", + # "download", ] PATH = "/account/" @@ -45,8 +47,8 @@ class AccountController(BaseController): self.ROUTINE_CHOICES = {filename: None for filename in self.ROUTINE_FILES} if session and obbff.USE_PROMPT_TOOLKIT: choices: dict = {c: {} for c in self.controller_choices} - choices["upload"]["--file"] = self.ROUTINE_CHOICES - choices["upload"]["-f"] = choices["upload"]["--file"] + # choices["upload"]["--file"] = self.ROUTINE_CHOICES + # choices["upload"]["-f"] = choices["upload"]["--file"] self.completer = NestedCompleter.from_nested_dict(choices) @@ -56,11 +58,11 @@ class AccountController(BaseController): mt = MenuText("account/", 100) mt.add_info("_info_") mt.add_cmd("sync") - mt.add_cmd("force") - mt.add_raw("\n") - mt.add_info("_routines_") - mt.add_cmd("upload") - mt.add_cmd("download") + mt.add_cmd("pull") + mt.add_cmd("defaults") + # mt.add_info("_routines_") + # mt.add_cmd("upload") + # mt.add_cmd("download") console.print(text=mt.menu_text, menu="Account") @log_start_end(log=logger) @@ -69,49 +71,53 @@ class AccountController(BaseController): FeatureFlagsController.set_feature_flag( "OPENBB_SYNC_ENABLED", not obbff.SYNC_ENABLED, force=True ) - User.update_flair() - def call_force(self, _): - """Force sync""" - console.print("Pull, Diff, Push") + def call_pull(self, _): + """Pull data""" + console.print("Pull, Diff and Merge.") pass - @log_start_end(log=logger) - def call_upload(self, other_args: List[str]): - """Upload""" - parser = argparse.ArgumentParser( - add_help=False, - formatter_class=argparse.ArgumentDefaultsHelpFormatter, - prog="load", - description="Load your portfolio transactions.", - ) - parser.add_argument( - "-f", - "--file", - type=str, - dest="file", - required="-h" not in other_args, - help="The file to be loaded", - choices={c: {} for c in self.ROUTINE_FILES}, - metavar="FILE", - ) - parser.add_argument( - "-n", - "--name", - type=str, - dest="name", - required="-h" not in other_args, - help="The name of the routine", - ) - if other_args and "-" not in other_args[0][0]: - other_args.insert(0, "-f") - ns_parser = self.parse_known_args_and_warn(parser, other_args) - if ns_parser: - routine = Local.get_routine(ns_parser.file) - if routine: - Hub.upload_routine(ns_parser.name, routine) + def call_defaults(self, _): + """Reset to defaults""" + console.print("No implemented yet.") + pass - @log_start_end(log=logger) - def call_download(self, _): - """Download""" - Hub.download_routine() + # @log_start_end(log=logger) + # def call_upload(self, other_args: List[str]): + # """Upload""" + # parser = argparse.ArgumentParser( + # add_help=False, + # formatter_class=argparse.ArgumentDefaultsHelpFormatter, + # prog="load", + # description="Load your portfolio transactions.", + # ) + # parser.add_argument( + # "-f", + # "--file", + # type=str, + # dest="file", + # required="-h" not in other_args, + # help="The file to be loaded", + # choices={c: {} for c in self.ROUTINE_FILES}, + # metavar="FILE", + # ) + # parser.add_argument( + # "-n", + # "--name", + # type=str, + # dest="name", + # required="-h" not in other_args, + # help="The name of the routine", + # ) + # if other_args and "-" not in other_args[0][0]: + # other_args.insert(0, "-f") + # ns_parser = self.parse_known_args_and_warn(parser, other_args) + # if ns_parser: + # routine = Local.get_routine(ns_parser.file) + # if routine: + # Hub.upload_routine(ns_parser.name, routine) + + # @log_start_end(log=logger) + # def call_download(self, _): + # """Download""" + # Hub.download_routine() diff --git a/openbb_terminal/miscellaneous/i18n/en.yml b/openbb_terminal/miscellaneous/i18n/en.yml index 85d54aef9d6..4816bb7c2cf 100644 --- a/openbb_terminal/miscellaneous/i18n/en.yml +++ b/openbb_terminal/miscellaneous/i18n/en.yml @@ -17,8 +17,9 @@ en: _configure_: Configure your own terminal _main_menu_: Main menu account/_info_: Synchronization - account/sync: Enable/disable sync - account/force: Force synchronization + account/sync: Send keys, settings and features flags on changes + account/pull: Pull keys, settings and feature flags from server + account/defaults: Reset to defaults account/_routines_: Routines account/upload: Upload routine account/download: Download routine diff --git a/openbb_terminal/session/local_model.py b/openbb_terminal/session/local_model.py index b43cb8a2d7d..04a1ca26b75 100644 --- a/openbb_terminal/session/local_model.py +++ b/openbb_terminal/session/local_model.py @@ -95,7 +95,6 @@ def apply_configs(configs: dict): # TODO: Find a cleaner way to check if user has sync enabled. obbff.SYNC_ENABLED = is_sync_enabled(settings) - User.update_flair() if obbff.SYNC_ENABLED: if settings: diff --git a/openbb_terminal/session/user.py b/openbb_terminal/session/user.py index f5fef75a425..238f38969c1 100644 --- a/openbb_terminal/session/user.py +++ b/openbb_terminal/session/user.py @@ -37,12 +37,7 @@ class User: username = "[" + username[:MAX_FLAIR_LEN] + "]" if obbff.USE_FLAIR == ":openbb" or username in obbff.USE_FLAIR: - - if obbff.SYNC_ENABLED: - flair = username + " 🟢" - else: - flair = username + " 🔴" - setattr(obbff, "USE_FLAIR", flair) + setattr(obbff, "USE_FLAIR", username + " 🦋") @classmethod def whoami(cls): @@ -51,9 +46,9 @@ class User: console.print(f"[info]email:[/info] {User._EMAIL}") console.print(f"[info]uuid:[/info] {User._UUID}") if obbff.SYNC_ENABLED: - sync = "enabled" + sync = "ON" else: - sync = "disabled" + sync = "OFF" console.print(f"[info]sync:[/info] {sync}\n") else: console.print("[info]Only you know...[/info]\n")