Coverage for src/ipyvizzustory/__init__.py: 100%
17 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-25 14:04 +0100
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-25 14:04 +0100
1"""Python integration of Vizzu-Story."""
4from .storylib.story import Step, Slide
7class Environment:
8 """A class for selecting the runtime environment."""
10 # pylint: disable=import-outside-toplevel
11 # pylint: disable=unused-import
13 @staticmethod
14 def get_story():
15 """A static method for importing the appropriate chart for the environment."""
17 if Environment.is_ipython(): # pragma: no cover
18 from .ipy_env.story import Story as JupyterStory
20 return JupyterStory
22 if Environment.is_streamlit(): # pragma: no cover
23 from .st_env.story import Story as StreamlitStory
25 return StreamlitStory
27 from .py_env.story import Story as PythonStory
29 return PythonStory
31 @staticmethod
32 def is_ipython():
33 """A static method for detecting Jupyter environment."""
34 try:
35 from IPython import get_ipython # type: ignore
37 return get_ipython()
38 except ImportError: # pragma: no cover
39 return None
41 @staticmethod
42 def is_streamlit():
43 """A static method for detecting Streamlit environment."""
44 try:
45 from streamlit.scriptrunner.script_run_context import get_script_run_ctx
47 return get_script_run_ctx()
48 except ImportError: # pragma: no cover
49 return None
52Story = Environment.get_story()