mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-06 17:31:53 +00:00
* comment call_news * remove news * remove keys controller * remove settings controller * remove ta forex * remove qa economy * remove ta stocks * remove qa stocks * remove fa stocks * remove ins stocks * remove gov stocks * remove dps stocks * remove ba stocks * remove bt stocks * remove stocks * remove stocks base controller class * ruff * remove qa forex * remove oanda * remove forex * remove forex * remove forex * remove mention to fx_tickers * remove ta crypto * remove qa crypto * remove dd crypto * remove crypto controller * remove crypto references * remove economy controller * remove economy folder * remoe etf controller * remove reports controller * remove dashboards controller * remove alt controller * rmeove etf files * remove alt files * remove custom reports * remove dashboard files * remove econometrics controller * remove forecast controller * remove reports files * remove forecast files * remove econometrics files * remove portfolio * remove futures * remove fixedincome * remove funds * remove sdk and common * remove all from init * remove reference to ipykernel * remove reference to ta_helpers * remove reference to ta_helpers * cleanup * adjustments to choices * remove old sdk generator * remove mention to dashboards * ruff * cleanup * remove logging infra * remove decorators * remove sdk audit * remove tought of the day * remove tought of the day * fix commands andmenus choices * fixing lints * ruffs * remove old tests
59 lines
1.6 KiB
Python
59 lines
1.6 KiB
Python
# This is for helpers that do NOT import any OpenBB Modules
|
|
import logging
|
|
from typing import Literal
|
|
|
|
from dotenv import load_dotenv
|
|
from rich.console import Console
|
|
|
|
from openbb_terminal.core.config.paths import (
|
|
PACKAGE_ENV_FILE,
|
|
REPOSITORY_ENV_FILE,
|
|
SETTINGS_ENV_FILE,
|
|
)
|
|
|
|
console = Console()
|
|
|
|
menus = Literal["", "featflags", "settings"]
|
|
|
|
|
|
def strtobool(val):
|
|
"""Convert a string representation of truth to true (1) or false (0).
|
|
|
|
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
|
|
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
|
|
'val' is anything else.
|
|
"""
|
|
val = str(val).lower()
|
|
if val in ("y", "yes", "t", "true", "on", "1"):
|
|
output = True
|
|
elif val in ("n", "no", "f", "false", "off", "0"):
|
|
output = False
|
|
else:
|
|
raise ValueError(f"invalid truth value {val}")
|
|
|
|
return output
|
|
|
|
|
|
def load_env_files():
|
|
"""
|
|
Loads the dotenv files in the following order:
|
|
1. Repository .env file
|
|
2. Package .env file
|
|
3. User .env file
|
|
|
|
This allows the user to override the package settings with their own
|
|
settings, and the package to override the repository settings.
|
|
|
|
openbb_terminal modules are reloaded to refresh config files with new env,
|
|
otherwise they will use cache with old variables.
|
|
"""
|
|
load_dotenv(REPOSITORY_ENV_FILE, override=True)
|
|
load_dotenv(PACKAGE_ENV_FILE, override=True)
|
|
load_dotenv(SETTINGS_ENV_FILE, override=True)
|
|
|
|
|
|
def remove_log_handlers():
|
|
"""Remove the log handlers - needs to be done before reloading modules."""
|
|
for handler in logging.root.handlers[:]:
|
|
logging.root.removeHandler(handler)
|