Coverage for src/ipyvizzustory/__init__.py: 100%
25 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-02-26 16:47 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-02-26 16:47 +0000
1"""
2Build, present and share animated data stories in `Jupyter Notebook` and similar environments.
4`ipyvizzu-story` package consists of two main parts:
6* [Storylib][ipyvizzustory.storylib]: environment independent modules
7* [Env][ipyvizzustory.env]: environment dependent modules
9`ipyvizzu-story` package tries to figure out the environment and import the correct type of `Story`,
10however `Story` could be imported with full path.
12`ipyvizzu-story` package imports the following objects in `__init__.py`:
15* `Story` from [Env.py.story][ipyvizzustory.env.py.story] or
16 [Env.ipy.story][ipyvizzustory.env.ipy.story] or
17 [Env.st.story][ipyvizzustory.env.st.story]
18* [Step][ipyvizzustory.storylib.story.Step]
19* [Slide][ipyvizzustory.storylib.story.Slide]
20"""
22from .__version__ import __version__, __version_info__, PYENV
24from .storylib.story import Step, Slide
26from .env.py.story import Story as PythonStory
28try:
29 from .env.ipy.story import Story as JupyterStory
30 import IPython
32 if not IPython.get_ipython():
33 raise ImportError("JupyterStory")
34except ImportError:
35 JupyterStory = None # type: ignore
37try:
38 from .env.st.story import Story as StreamlitStory
39 import streamlit as st
41 if hasattr(st, "runtime"):
42 ctx = st.runtime.scriptrunner.get_script_run_ctx()
43 else:
44 ctx = st.scriptrunner.script_run_context.get_script_run_ctx() # type: ignore # pylint: disable=no-member
46 if not ctx:
47 raise ImportError("StreamlitStory")
48except ImportError:
49 StreamlitStory = None # type: ignore
52def get_story():
53 """
54 A method for returning the appropriate Story for the environment.
56 Returns:
57 (Union[ipyvizzustory.env.py.story.Story, ipyvizzustory.env.ipy.story.Story, ipyvizzustory.env.st.story.Story]):
58 The appropriate `Story` for the environment.
59 """ # pylint: disable=line-too-long
61 return JupyterStory or StreamlitStory or PythonStory # type: ignore
64Story = get_story()
65"""
66Available types:
68* [Jupyter/IPython Story][ipyvizzustory.env.ipy.story.Story]
69* [Streamlit Story][ipyvizzustory.env.st.story.Story]
70* [Panel Story][ipyvizzustory.env.pn.story.Story]
71* [Python Story][ipyvizzustory.env.py.story.Story]
72"""
74__all__ = ["get_story", "Story", "Slide", "Step"]