mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-26 03:02:00 +00:00
add _try_to_login to sdk generation, fix _chart in about() url
This commit is contained in:
@@ -59,6 +59,13 @@ class SDKLogger:
|
||||
setup_logging()
|
||||
log_all_settings()
|
||||
|
||||
@staticmethod
|
||||
def _try_to_login(sdk: "OpenBBSDK"):
|
||||
if User.is_guest() and is_auth_enabled():
|
||||
try:
|
||||
sdk.login()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
openbb = OpenBBSDK()\r\r
|
||||
"""
|
||||
@@ -478,6 +485,9 @@ class BuildCategoryModelClasses:
|
||||
if root_attrs:
|
||||
self.write_class_attr_docs(root_attrs, f, False, True)
|
||||
self.write_class_attributes(root_attrs, f)
|
||||
f.seek(f.tell() - 2, os.SEEK_SET)
|
||||
f.truncate()
|
||||
f.write(" SDKLogger._try_to_login(self)\r\r")
|
||||
|
||||
for category in self.categories:
|
||||
self.write_class_property(category, f)
|
||||
@@ -514,8 +524,9 @@ class BuildCategoryModelClasses:
|
||||
self.write_sdk_controller_file(category, d)
|
||||
self.write_sdk_file()
|
||||
|
||||
for path in ["sdk.py", "core/sdk", "core/sdk/models", "core/sdk/controllers"]:
|
||||
for file in (REPO_ROOT / path).glob("*.py"):
|
||||
for path in ["", "core/sdk", "core/sdk/models", "core/sdk/controllers"]:
|
||||
pattern = "*.py" if path else "sdk.py"
|
||||
for file in (REPO_ROOT / path).glob(pattern):
|
||||
with open(file, "rb") as f:
|
||||
content = f.read()
|
||||
with open(file, "wb") as f:
|
||||
|
||||
@@ -92,7 +92,7 @@ class Operation:
|
||||
# pylint: disable=C0415
|
||||
import webbrowser
|
||||
|
||||
trail = "/".join(self._trail.split("."))
|
||||
trail = "/".join(self._trail.split(".")).replace("_chart", "")
|
||||
url = f"https://docs.openbb.co/sdk/reference/{trail}"
|
||||
webbrowser.open(url)
|
||||
|
||||
@@ -324,6 +324,7 @@ class OperationLogger:
|
||||
def get_sdk_imports_text() -> str:
|
||||
"""Return the text for the SDK imports."""
|
||||
sdk_imports = """\"\"\"OpenBB Terminal SDK.\"\"\"
|
||||
# ######### THIS FILE IS AUTO GENERATED - ANY CHANGES WILL BE VOID ######### #
|
||||
# flake8: noqa
|
||||
# pylint: disable=unused-import,wrong-import-order
|
||||
# pylint: disable=C0302,W0611,R0902,R0903,C0412,C0301,not-callable
|
||||
@@ -347,6 +348,7 @@ from openbb_terminal.core.sdk import (
|
||||
)
|
||||
from openbb_terminal import feature_flags as obbff
|
||||
from openbb_terminal.session.user import User
|
||||
from openbb_terminal.terminal_helper import is_auth_enabled
|
||||
|
||||
if User.is_guest():
|
||||
load_dotenv_and_reload_configs()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
"""OpenBB Terminal SDK."""
|
||||
# ######### THIS FILE IS AUTO GENERATED - ANY CHANGES WILL BE VOID ######### #
|
||||
# flake8: noqa
|
||||
# pylint: disable=unused-import,wrong-import-order
|
||||
# pylint: disable=C0302,W0611,R0902,R0903,C0412,C0301,not-callable
|
||||
@@ -22,6 +23,7 @@ from openbb_terminal.core.sdk import (
|
||||
)
|
||||
from openbb_terminal import feature_flags as obbff
|
||||
from openbb_terminal.session.user import User
|
||||
from openbb_terminal.terminal_helper import is_auth_enabled
|
||||
|
||||
if User.is_guest():
|
||||
load_dotenv_and_reload_configs()
|
||||
@@ -48,6 +50,7 @@ class OpenBBSDK:
|
||||
self.logout = lib.sdk_session.logout
|
||||
self.news = lib.common_feedparser_model.get_news
|
||||
self.whoami = lib.sdk_session.whoami
|
||||
SDKLogger._try_to_login(self)
|
||||
|
||||
@property
|
||||
def alt(self):
|
||||
@@ -530,5 +533,13 @@ class SDKLogger:
|
||||
setup_logging()
|
||||
log_all_settings()
|
||||
|
||||
@staticmethod
|
||||
def _try_to_login(sdk: "OpenBBSDK"):
|
||||
if User.is_guest() and is_auth_enabled():
|
||||
try:
|
||||
sdk.login()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
openbb = OpenBBSDK()
|
||||
|
||||
Reference in New Issue
Block a user