mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-05-22 22:41:07 +08:00
* section description
* remove comment
* show msg only if it's an OBBject
* ommit coverage from menus
* styling: no new lines after settings
* Bugfix/cli max rows (#6374)
* fix: cli max rows
* fix: settings menu
---------
Co-authored-by: Henrique Joaquim <henriquecjoaquim@gmail.com>
* add a new line only to separate menus and commands
* if there's no menu description on reference.json, use the commands of that menu to create a pseudo description
* use the PATH instead in the top of the menu help
* default name len to 23
* keep command on the obbject so it can be shown on the results
* left spacing regardless description
* display cached results on every platform menu's help
* display info instead of sections and display cached results
* prepend OBB to use on the --data
* config to set number of cached results to display
* correct hub link
* Save routines locally if not logged in.
* Change the exit message
* Point to new docs on first launch.
* proper checking of max_obbjects_exceeded
* fix global flag on local routines
* Remove language from settings as it is not supported.
* Remove rcontext flag
* export to account multiple formats
* Revert "Remove rcontext flag"
This reverts commit 8a1f64b71c.
* Remove
* leftover
* properly match provider being used with provider arguments so that kwargs are correctly filtered
---------
Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com>
Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
Co-authored-by: James Maslek <jmaslek11@gmail.com>
74 lines
2.1 KiB
Python
74 lines
2.1 KiB
Python
"""Settings model"""
|
|
|
|
from typing import Any
|
|
|
|
from dotenv import dotenv_values, set_key
|
|
from openbb_cli.config.constants import ENV_FILE_SETTINGS
|
|
from pydantic import BaseModel, ConfigDict, model_validator
|
|
|
|
|
|
class Settings(BaseModel):
|
|
"""Settings model."""
|
|
|
|
# Platform CLI version
|
|
VERSION: str = "1.0.0"
|
|
|
|
# DEVELOPMENT FLAGS
|
|
TEST_MODE: bool = False
|
|
DEBUG_MODE: bool = False
|
|
DEV_BACKEND: bool = False
|
|
|
|
# FEATURE FLAGS
|
|
FILE_OVERWRITE: bool = False
|
|
SHOW_VERSION: bool = True
|
|
USE_INTERACTIVE_DF: bool = True
|
|
USE_CLEAR_AFTER_CMD: bool = False
|
|
USE_DATETIME: bool = True
|
|
USE_PROMPT_TOOLKIT: bool = True
|
|
ENABLE_EXIT_AUTO_HELP: bool = True
|
|
REMEMBER_CONTEXTS: bool = True
|
|
ENABLE_RICH_PANEL: bool = True
|
|
TOOLBAR_HINT: bool = True
|
|
SHOW_MSG_OBBJECT_REGISTRY: bool = False
|
|
|
|
# GENERAL
|
|
TIMEZONE: str = "America/New_York"
|
|
FLAIR: str = ":openbb"
|
|
PREVIOUS_USE: bool = False
|
|
N_TO_KEEP_OBBJECT_REGISTRY: int = 10
|
|
N_TO_DISPLAY_OBBJECT_REGISTRY: int = 5
|
|
|
|
# STYLE
|
|
RICH_STYLE: str = "dark"
|
|
|
|
# OUTPUT
|
|
ALLOWED_NUMBER_OF_ROWS: int = 20
|
|
ALLOWED_NUMBER_OF_COLUMNS: int = 5
|
|
|
|
# OPENBB
|
|
HUB_URL: str = "https://my.openbb.co"
|
|
BASE_URL: str = "https://payments.openbb.co"
|
|
|
|
model_config = ConfigDict(validate_assignment=True)
|
|
|
|
def __repr__(self) -> str:
|
|
"""Return a string representation of the model."""
|
|
return f"{self.__class__.__name__}\n\n" + "\n".join(
|
|
f"{k}: {v}" for k, v in self.model_dump().items()
|
|
)
|
|
|
|
@model_validator(mode="before")
|
|
@classmethod
|
|
def from_env(cls, values: dict) -> dict:
|
|
"""Load settings from .env."""
|
|
settings = {}
|
|
settings.update(dotenv_values(ENV_FILE_SETTINGS))
|
|
settings.update(values)
|
|
filtered = {k.replace("OPENBB_", ""): v for k, v in settings.items()}
|
|
return filtered
|
|
|
|
def set_item(self, key: str, value: Any) -> None:
|
|
"""Set an item in the model and save to .env."""
|
|
setattr(self, key, value)
|
|
set_key(str(ENV_FILE_SETTINGS), "OPENBB_" + key, str(value))
|