mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 05:21:48 +00:00
implementing chavi suggestions
This commit is contained in:
@@ -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()
|
||||
|
||||
5
openbb_terminal/miscellaneous/i18n/en.yml
vendored
5
openbb_terminal/miscellaneous/i18n/en.yml
vendored
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user