Fix bad api output (#2659)

Co-authored-by: James Maslek <jmaslek11@gmail.com>
This commit is contained in:
Colin Delahunty
2022-09-29 06:48:27 +02:00
committed by GitHub
parent 3685001fba
commit c052ed3e05

View File

@@ -7,7 +7,7 @@ from inspect import signature, Parameter
import types
import functools
import importlib
from typing import Optional, Callable
from typing import Optional, Callable, List
from openbb_terminal.helper_classes import TerminalStyle # noqa: F401
from openbb_terminal import helper_funcs as helper # noqa: F401
@@ -2065,12 +2065,14 @@ class Loader:
def load_menus(self):
"""Creates the API structure (see openbb.stocks.command) by setting attributes and saving the functions"""
def menu_message(menu: str, function_map: dict):
def menu_message(menu: str, full_path: List[str], function_map: dict):
"""Creates a callable function, which prints a menus help message
Parameters
----------
menu: str
Menu for which the help message is generated
full_path: List[str]
The list to get to the path
function_map: dict
Dictionary with the functions and their virtual paths
Returns
@@ -2078,7 +2080,8 @@ class Loader:
Callable:
Function which prints help message
"""
filtered_dict = {k: v for (k, v) in function_map.items() if menu in k}
path_str = ".".join(full_path)
filtered_dict = {k: v for (k, v) in function_map.items() if path_str in k}
def f():
string = menu.upper() + " Menu\n\nThe api commands of the the menu:"
@@ -2099,7 +2102,12 @@ class Loader:
for menu in virtual_path_split[:-1]:
if not hasattr(previous_menu, menu):
next_menu = MenuFiller(function=menu_message(menu, function_map))
partial_path = virtual_path_split[
: virtual_path_split.index(menu) + 1
]
next_menu = MenuFiller(
function=menu_message(menu, partial_path, function_map)
)
setattr(previous_menu, menu, next_menu)
previous_menu = getattr(previous_menu, menu)
setattr(previous_menu, last_virtual_path, function)