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

Improving styles loading #2569

Merged
merged 7 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Core : styles
  • Loading branch information
Chavithra committed Sep 20, 2022
commit 8e5bc5f350c43818e53b8331eb19c1ef98d41680
1 change: 1 addition & 0 deletions openbb_terminal/core/config/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@

USER_DATA_DIRECTORY = HOME_DIRECTORY / "OpenBBUserData"

REPOSITORY_STYLES_DIRECTORY = USER_DATA_DIRECTORY / "styles"
USER_STYLES_DIRECTORY = USER_DATA_DIRECTORY / "styles"
24 changes: 3 additions & 21 deletions openbb_terminal/helper_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import matplotlib.pyplot as plt
from matplotlib import font_manager, ticker

from openbb_terminal.core.config.paths import USER_STYLES_DIRECTORY, REPOSITORY_DIRECTORY
from openbb_terminal.core.config.paths import REPOSITORY_STYLES_DIRECTORY, USER_STYLES_DIRECTORY


class LineAnnotateDrawer:
Expand Down Expand Up @@ -100,9 +100,8 @@ class TerminalStyle:
styles as python dictionaries.
"""

_STYLES_FOLDER = USER_STYLES_DIRECTORY
DEFAULT_STYLES_LOCATION = os.path.join(_STYLES_FOLDER, "default")
USER_STYLES_LOCATION = os.path.join(_STYLES_FOLDER, "user")
DEFAULT_STYLES_LOCATION = REPOSITORY_STYLES_DIRECTORY / "default"
USER_STYLES_LOCATION = USER_STYLES_DIRECTORY / "user"

mpl_styles_available: Dict[str, str] = {}
mpl_style: str = ""
Expand Down Expand Up @@ -151,23 +150,6 @@ def __init__(
"""
# To import all styles from terminal repo folder to user data

if len(os.listdir(self._STYLES_FOLDER)) == 0:
repo_styles = REPOSITORY_DIRECTORY.joinpath("styles")
for root, _, filenames in os.walk(repo_styles.joinpath("default")):
os.mkdir(Path(self._STYLES_FOLDER).joinpath("default"))
for style in filenames:
copyfile(
os.path.join(root, style),
Path(self._STYLES_FOLDER).joinpath("default", style),
)
for root, _, filenames in os.walk(repo_styles.joinpath("user")):
os.mkdir(Path(self._STYLES_FOLDER).joinpath("user"))
for style in filenames:
copyfile(
os.path.join(root, style),
Path(self._STYLES_FOLDER).joinpath("user", style),
)

for folder in [self.DEFAULT_STYLES_LOCATION, self.USER_STYLES_LOCATION]:
self.load_available_styles_from_folder(folder)
self.load_custom_fonts_from_folder(folder)
Expand Down