mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
Merge pull request #190 from clothespin/prompt-toolkit-inputhook
Registers pyplot.draw as inputhook for prompt_toolkit
This commit is contained in:
3
.github/workflows/Mac.yml
vendored
3
.github/workflows/Mac.yml
vendored
@@ -1,4 +1,7 @@
|
||||
name: Mac OS X Full Clean Build with ML
|
||||
env:
|
||||
GTFF_USE_PROMPT_TOOLKIT: false
|
||||
GTFF_USE_ION: false
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
|
||||
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@@ -1,4 +1,7 @@
|
||||
name: Tests
|
||||
env:
|
||||
GTFF_USE_PROMPT_TOOLKIT: false
|
||||
GTFF_USE_ION: false
|
||||
on: [pull_request, push]
|
||||
jobs:
|
||||
linting:
|
||||
|
||||
3
.github/workflows/windows.yml
vendored
3
.github/workflows/windows.yml
vendored
@@ -1,4 +1,7 @@
|
||||
name: Windows 10 Full Clean Build with ML
|
||||
env:
|
||||
GTFF_USE_PROMPT_TOOLKIT: false
|
||||
GTFF_USE_ION: false
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
from distutils.util import strtobool
|
||||
import os
|
||||
|
||||
USE_COLOR = os.getenv("GTFF_USE_COLOR") or True
|
||||
USE_COLOR = strtobool(os.getenv("GTFF_USE_COLOR", "True"))
|
||||
USE_FLAIR = os.getenv("GTFF_USE_FLAIR") or "stars"
|
||||
USE_ION = os.getenv("GTFF_USE_ION") or True
|
||||
USE_PROMPT_TOOLKIT = os.getenv("GTFF_USE_PROMPT_TOOLKIT") or False
|
||||
USE_ION = strtobool(os.getenv("GTFF_USE_ION", "True"))
|
||||
USE_PROMPT_TOOLKIT = strtobool(os.getenv("GTFF_USE_PROMPT_TOOLKIT", "False"))
|
||||
|
||||
# Enable Prediction features
|
||||
ENABLE_PREDICT = os.getenv("GTFF_ENABLE_PREDICT") or False
|
||||
ENABLE_PREDICT = strtobool(os.getenv("GTFF_ENABLE_PREDICT", "False"))
|
||||
|
||||
# Enable plot autoscaling
|
||||
USE_PLOT_AUTOSCALING = os.getenv("GTFF_USE_PLOT_AUTOSCALING") or False
|
||||
USE_PLOT_AUTOSCALING = strtobool(os.getenv("GTFF_USE_PLOT_AUTOSCALING", "False"))
|
||||
|
||||
@@ -1,11 +1,25 @@
|
||||
import os
|
||||
|
||||
from matplotlib import pyplot
|
||||
|
||||
from prompt_toolkit import PromptSession
|
||||
from prompt_toolkit.eventloop.inputhook import set_eventloop_with_inputhook
|
||||
from prompt_toolkit.history import FileHistory
|
||||
|
||||
|
||||
def inputhook(inputhook_context):
|
||||
while not inputhook_context.input_is_ready():
|
||||
pyplot.pause(0.1)
|
||||
return False
|
||||
|
||||
|
||||
history_file = os.path.join(os.path.expanduser("~"), ".gamestonk_terminal.his")
|
||||
|
||||
try:
|
||||
session = PromptSession(history=FileHistory(history_file))
|
||||
set_eventloop_with_inputhook(inputhook)
|
||||
except Exception as e: # noqa: F841
|
||||
print(
|
||||
"WARNING: Prompt toolkit is turned on but did not initialize successfully. Falling back to input()..."
|
||||
)
|
||||
session = None
|
||||
|
||||
Reference in New Issue
Block a user