From e00534c9d16880efbc48ad25d7dc6935bd0ff856 Mon Sep 17 00:00:00 2001 From: "Minha, Jeong" <60059706+PzaThief@users.noreply.github.com> Date: Sun, 8 May 2022 02:53:52 +0900 Subject: [PATCH] Duplicated code remove (#1780) * print function to console.print * remove duplicated and worng positioned class * black formatter apply * circular import resolve * add pylint import-outside-toplevel disable Co-authored-by: didierlopes.eth --- openbb_terminal/helper_classes.py | 9 +++++-- openbb_terminal/helper_funcs.py | 43 ------------------------------- 2 files changed, 7 insertions(+), 45 deletions(-) diff --git a/openbb_terminal/helper_classes.py b/openbb_terminal/helper_classes.py index 75a09a9d688..ad8ad5eb398 100644 --- a/openbb_terminal/helper_classes.py +++ b/openbb_terminal/helper_classes.py @@ -17,15 +17,20 @@ class LineAnnotateDrawer: def __init__(self, ax: matplotlib.axes = None): self.ax = ax + # pylint: disable=import-outside-toplevel def draw_lines_and_annotate(self): """Draw lines.""" - print("Click twice for annotation.\nClose window to keep using terminal.\n") + from openbb_terminal.rich_config import console + + console.print( + "Click twice for annotation.\nClose window to keep using terminal.\n" + ) while True: xy = plt.ginput(2) # Check whether the user has closed the window or not if not plt.get_fignums(): - print("") + console.print("") return if len(xy) == 2: diff --git a/openbb_terminal/helper_funcs.py b/openbb_terminal/helper_funcs.py index 7a4c35d0e72..ebcafba4653 100644 --- a/openbb_terminal/helper_funcs.py +++ b/openbb_terminal/helper_funcs.py @@ -1318,49 +1318,6 @@ def get_rf() -> float: return 0.02 -class LineAnnotateDrawer: - """Line drawing class.""" - - def __init__(self, ax: matplotlib.axes = None): - self.ax = ax - - def draw_lines_and_annotate(self): - # ymin, _ = self.ax.get_ylim() - # xmin, _ = self.ax.get_xlim() - # self.ax.plot( - # [xmin, xmin], - # [ymin, ymin], - # lw=0, - # color="white", - # label="X - leave interactive mode\nClick twice for annotation", - # ) - # self.ax.legend(handlelength=0, handletextpad=0, fancybox=True, loc=2) - # self.ax.figure.canvas.draw() - """Draw lines.""" - console.print( - "Click twice for annotation.\nClose window to keep using terminal.\n" - ) - - while True: - xy = plt.ginput(2) - # Check whether the user has closed the window or not - if not plt.get_fignums(): - console.print("") - return - - if len(xy) == 2: - x = [p[0] for p in xy] - y = [p[1] for p in xy] - - if (x[0] == x[1]) and (y[0] == y[1]): - txt = input("Annotation: ") - self.ax.annotate(txt, (x[0], y[1]), ha="center", va="center") - else: - self.ax.plot(x, y) - - self.ax.figure.canvas.draw() - - def system_clear(): """Clear screen""" os.system("cls||clear") # nosec