Files
OpenBB/openbb_terminal/core/models/preferences_model.py
montezdesousa b6b42afd71 Hub | Add colors, sources sync (#4546)
* fix show version

* update login prompt and account

* update set preference

* fix account controller

* block login/logout if not called from account

* change conditions to start terminal

* fix required args account model

* add not to login command

* pylint

* accounte controller messages

* set default user when logout

* logout then show menu

* remove unused functions

* fix logging bug

* ruff

* fix account unittests

* fix session unittests

* refactor colors preference

* no theme, no party

* add colors sync

* dynamic theme

* add comment

* add colors to settings

* ruff

* linting

* update menu desc

* adjust keys sync flag

* write to dotenv sync flag

* english

* fix pull command

* fix edge cases

* handle some errors

* small bug

* change func name

* pylint

* no light

* colors preview

* ruff

* fix login logout preferences

* ruff

* delete folder

* pylint

* default, custom, hub

* fix clear

* docstring

* add preference exceptions

* set only rich style

* request theme only if hub

* linting

* change guest msg

* add option to update chart style on the fly

* apply style

* rollback to old terminal style

* fix console theme

* remove print

* remove hub rich style

* ruff

* mypy

* black

* Hub | Add sources sync (#4565)

* Add sources model

* adapt session model

* fetch sources dict

* rename local funcs

* set sources inside current user

* set sources inside current user

* generate sources dict from hub

* fix dict generator

* send request to hub

* fix conflict

* revert datasources to develop head

* fix docstring

* avoid invalid patch types

* add default option to sources

* fix small bug on sources

* ruff

* black

* remove (

* mypy failing only on git

* ignore mypy

* pylint

* fix settings controller

* Tests: fix keys model writing to .env

* fix keys controller test writing to .env

* ruff

* Test: fix account controller

* Test: fix account controller pull

* Tests: fix launch terminal

* Test: add sources to user object

* Tests: fix clear cmd tests

* ruff

* revert core/sdk changes

* TerminalStyle docstring

* upload config docstring

* remove comment

* remove unecessary pylint disable

* revert openbb_terminal/sdk changes

* Terminal style docstring

* docstring

* remove unecessary changes

* add TODO

* add other todo

* Tests: prevent sync from being written in .env

* change clear msg

* display sources source on menu

* update settings controller

* display keys source

* black

* sync not needed for pull

* remove sync from apply configs

* change func name for consistency

* Update test_keys_model.py

* save rich style in user folder

* search recursively inside styles

* set hub theme by default

* remove debug print

* allow any plot style

* comment plotstyle sync for now

* fix sources set terminal to hub

* ruff

* rewrite cassettes

* remove repeated settings

* rewrite expected
2023-03-27 16:59:36 +00:00

108 lines
4.1 KiB
Python

import os
from typing import Optional
from pydantic import NonNegativeInt, PositiveFloat, PositiveInt
from pydantic.dataclasses import dataclass
from openbb_terminal.core.config.paths import (
HOME_DIRECTORY,
USER_DATA_SOURCES_DEFAULT_FILE,
)
from openbb_terminal.core.models import BaseModel
# pylint: disable=too-many-instance-attributes, disable=no-member, useless-parent-delegation
@dataclass(config=dict(validate_assignment=True, frozen=True))
class PreferencesModel(BaseModel):
"""Data model for preferences."""
# PLOT
# Plot backend
# Examples:
# "tkAgg" - This uses the tkinter library. If unsure, set to this
# "module://backend_interagg" - This is what pycharm defaults to in Scientific Mode
# "MacOSX" - Mac default. Does not work with backtesting
# "Qt5Agg" - This requires the PyQt5 package is installed
# See more: https://matplotlib.org/stable/tutorials/introductory/usage.html#the-builtin-backends
PLOT_BACKEND: Optional[str] = None
PLOT_DPI: PositiveInt = 100
PLOT_HEIGHT: PositiveInt = 500
PLOT_WIDTH: PositiveInt = 800
PLOT_HEIGHT_PERCENTAGE: PositiveFloat = 50.0
PLOT_WIDTH_PERCENTAGE: PositiveFloat = 70.0
# Whether to open plot image exports after they are created
PLOT_OPEN_EXPORT: bool = False
# Use interactive window to display plots
PLOT_ENABLE_PYWRY: bool = True
PLOT_PYWRY_WIDTH: PositiveInt = 1400
PLOT_PYWRY_HEIGHT: PositiveInt = 762
# FEATURE FLAGS
SYNC_ENABLED: bool = True
FILE_OVERWRITE: bool = False
SHOW_VERSION: bool = True
RETRY_WITH_LOAD: bool = False
USE_TABULATE_DF: bool = True
# Use interactive window to display dataframes with options to sort, filter, etc.
USE_INTERACTIVE_DF: bool = True
USE_CLEAR_AFTER_CMD: bool = False
USE_COLOR: bool = True
USE_DATETIME: bool = True
# Enable interactive matplotlib mode: change variable name to be more descriptive and delete comment
USE_ION: bool = True
USE_WATERMARK: bool = True
USE_CMD_LOCATION_FIGURE: bool = True
USE_PROMPT_TOOLKIT: bool = True
USE_PLOT_AUTOSCALING: bool = False
ENABLE_THOUGHTS_DAY: bool = False
ENABLE_QUICK_EXIT: bool = False
OPEN_REPORT_AS_HTML: bool = True
ENABLE_EXIT_AUTO_HELP: bool = True
REMEMBER_CONTEXTS: bool = True
ENABLE_RICH: bool = True
ENABLE_RICH_PANEL: bool = True
ENABLE_CHECK_API: bool = True
TOOLBAR_HINT: bool = True
TOOLBAR_TWEET_NEWS: bool = False
# TOOLBAR
TOOLBAR_TWEET_NEWS_SECONDS_BETWEEN_UPDATES: PositiveInt = 300
TOOLBAR_TWEET_NEWS_ACCOUNTS_TO_TRACK: str = (
"WatcherGuru,unusual_whales,gurgavin,CBSNews"
)
TOOLBAR_TWEET_NEWS_KEYWORDS: str = "BREAKING,JUST IN"
TOOLBAR_TWEET_NEWS_NUM_LAST_TWEETS_TO_READ: PositiveInt = 3
# GENERAL
PREVIOUS_USE: bool = False
TIMEZONE: str = "America/New_York"
FLAIR: str = ":openbb"
USE_LANGUAGE: str = "en"
REQUEST_TIMEOUT: PositiveInt = 5
MONITOR: NonNegativeInt = 0
# STYLE
MPL_STYLE: str = "dark"
PMF_STYLE: str = "dark"
RICH_STYLE: str = "dark"
PLOT_STYLE: str = "dark"
# PATHS
PREFERRED_DATA_SOURCE_FILE: str = str(USER_DATA_SOURCES_DEFAULT_FILE)
GUESS_EASTER_EGG_FILE: str = os.getcwd() + os.path.sep + "guess_game.json"
USER_DATA_DIRECTORY = HOME_DIRECTORY / "OpenBBUserData"
USER_EXPORTS_DIRECTORY = USER_DATA_DIRECTORY / "exports"
USER_CUSTOM_IMPORTS_DIRECTORY = USER_DATA_DIRECTORY / "custom_imports"
USER_PORTFOLIO_DATA_DIRECTORY = USER_DATA_DIRECTORY / "portfolio"
USER_ROUTINES_DIRECTORY = USER_DATA_DIRECTORY / "routines"
USER_PRESETS_DIRECTORY = USER_DATA_DIRECTORY / "presets"
USER_REPORTS_DIRECTORY = USER_DATA_DIRECTORY / "reports"
USER_CUSTOM_REPORTS_DIRECTORY = USER_DATA_DIRECTORY / "reports" / "custom reports"
USER_FORECAST_MODELS_DIRECTORY = USER_DATA_DIRECTORY / "exports" / "forecast_models"
USER_FORECAST_WHISPER_DIRECTORY = USER_DATA_DIRECTORY / "exports" / "whisper"
USER_STYLES_DIRECTORY = USER_DATA_DIRECTORY / "styles"
def __repr__(self) -> str: # pylint: disable=useless-super-delegation
return super().__repr__()