Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New path for routines #2632

Merged
merged 7 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions openbb_terminal/core/config/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ def get_user_data_directory():
USER_EXPORTS_DIRECTORY = USER_DATA_DIRECTORY / "exports"

CUSTOM_IMPORTS_DIRECTORY = USER_DATA_DIRECTORY / "custom_imports"

ROUTINES_DIRECTORY = USER_DATA_DIRECTORY / "routines"
2 changes: 2 additions & 0 deletions openbb_terminal/core/config/paths_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
REPOSITORY_ENV_FILE,
CUSTOM_IMPORTS_DIRECTORY,
USER_EXPORTS_DIRECTORY,
ROUTINES_DIRECTORY,
)


Expand Down Expand Up @@ -42,6 +43,7 @@ def create_files(list_files: List):
CUSTOM_IMPORTS_DIRECTORY / "dashboards",
USER_EXPORTS_DIRECTORY,
USER_EXPORTS_DIRECTORY / "reports",
ROUTINES_DIRECTORY,
]
dirs_files = [USER_ENV_FILE, REPOSITORY_ENV_FILE]
create_paths(dirs_list)
Expand Down
22 changes: 11 additions & 11 deletions terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
USER_ENV_FILE,
REPOSITORY_ENV_FILE,
USER_EXPORTS_DIRECTORY,
ROUTINES_DIRECTORY,
)
from openbb_terminal.core.log.generation.path_tracking_file_handler import (
PathTrackingFileHandler,
Expand Down Expand Up @@ -89,13 +90,16 @@ class TerminalController(BaseController):
]

PATH = "/"
ROUTINE_CHOICES = {
file: None
for file in os.listdir(
os.path.join(os.path.abspath(os.path.dirname(__file__)), "routines")
)
if file.endswith(".openbb")

ROUTINE_FILES = {
filepath.name: filepath
for filepath in (REPOSITORY_DIRECTORY / "routines").rglob("*.openbb")
}
ROUTINE_FILES.update(
{filepath.name: filepath for filepath in ROUTINES_DIRECTORY.rglob("*.openbb")}
)

ROUTINE_CHOICES = {filename: None for filename in ROUTINE_FILES}

GUESS_TOTAL_TRIES = 0
GUESS_NUMBER_TRIES_LEFT = 0
Expand Down Expand Up @@ -485,11 +489,7 @@ def call_exe(self, other_args: List[str]):
if ns_parser_exe:
if ns_parser_exe.path:
if ns_parser_exe.path in self.ROUTINE_CHOICES:
path = os.path.join(
os.path.abspath(os.path.dirname(__file__)),
"routines",
ns_parser_exe.path,
)
path = self.ROUTINE_FILES[ns_parser_exe.path]
else:
path = ns_parser_exe.path

Expand Down