From 21983978598a9573b4565a2447d9cbebae3a5a7c Mon Sep 17 00:00:00 2001 From: hjoaquim Date: Thu, 9 May 2024 00:23:45 +0100 Subject: [PATCH] prepend OBB to use on the --data --- .../controllers/base_platform_controller.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cli/openbb_cli/controllers/base_platform_controller.py b/cli/openbb_cli/controllers/base_platform_controller.py index da2fcefaae6..3b793f83fee 100644 --- a/cli/openbb_cli/controllers/base_platform_controller.py +++ b/cli/openbb_cli/controllers/base_platform_controller.py @@ -75,17 +75,20 @@ class PlatformController(BaseController): for _, trl in self.translators.items(): for action in trl._parser._actions: # pylint: disable=protected-access if action.dest == "data": - action.choices = range(len(session.obbject_registry.obbjects)) - action.type = int + action.choices = [ + "OBB" + str(i) + for i in range(len(session.obbject_registry.obbjects)) + ] + action.type = str action.nargs = None def _intersect_data_processing_commands(self, ns_parser): """Intersect data processing commands and change the obbject id into an actual obbject.""" - if hasattr(ns_parser, "data") and ns_parser.data in range( - len(session.obbject_registry.obbjects) - ): - obbject = session.obbject_registry.get(ns_parser.data) - setattr(ns_parser, "data", obbject.results) + if hasattr(ns_parser, "data"): + ns_parser.data = int(ns_parser.data.replace("OBB", "")) + if ns_parser.data in range(len(session.obbject_registry.obbjects)): + obbject = session.obbject_registry.get(ns_parser.data) + setattr(ns_parser, "data", obbject.results) return ns_parser